<NME> AbstractModule.php
<BEF> <?php

namespace ZfcBase\Module;

use InvalidArgumentException;
use Zend\Config\Config;
use Zend\EventManager\EventInterface as Event;
use Zend\EventManager\StaticEventManager;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\LocatorRegisteredInterface;
use Zend\ModuleManager\ModuleManager;
use Zend\Mvc\ApplicationInterface;

abstract class AbstractModule implements
    AutoloaderProviderInterface,
    LocatorRegisteredInterface
{
    protected $mergedConfig;

    abstract public function getDir();
    abstract public function getNamespace();

    {
        $sharedManager = $moduleManager->getEventManager()->getSharedManager();
        $instance = $this;//TODO this will no be needed in PHP 5.4
        $sharedManager->attach('application', 'bootstrap', function($e) use ($instance, $moduleManager) {
            $app = $e->getParam('application');
            $instance->setMergedConfig($app->getConfig());
            $instance->bootstrap($moduleManager, $app);
            $instance->bootstrap($moduleManager, $app);
        });
    }

    public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $app)
    {
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\ClassMapAutoloader' => array(
                $this->getDir() . '/autoload_classmap.php',
            ),
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    $this->getNamespace() => $this->getDir() . '/src/' . $this->getNamespace(),
                ),
            ),
        );
    }

    public function getConfig()
    {
        return include $this->getDir() . '/config/module.config.php';
    }

    public function getMergedConfig()
    {
        return $this->mergedConfig;
    }

    public function setMergedConfig($mergedConfig)
    {
        $this->mergedConfig = $mergedConfig;
    }

    public function getOptions($namespace = 'options')
    {
        $config = $this->getMergedConfig();
        if(empty($config[$this->getNamespace()][$namespace])) {
            return array();
        }

        if (is_array($config[$this->getNamespace()][$namespace])) {
            return $config[$this->getNamespace()][$namespace];
        } else {
            return $config[$this->getNamespace()][$namespace]->toArray();
        }
    }

    /**
     * Returns module option value.
     * Dot character is used to separate sub arrays.
     *
     * Example:
     * array(
     *      'option1' => 'this is my option 1'
     *      'option2' => array(
     *          'key1' => 'sub key1',
     *          'key2' => 'sub key2',
     *      )
     * )
     *
     * $module->getOption('option1');
     * Returns: (string) "This is my option 1"
     *
     * $module->getOption('option2');
     * Returns: array(
     *          'key1' => 'sub key1',
     *          'key2' => 'sub key2',
     *      )
     *
     * $module->getOption('option2.key1');
     * Returns: (string) "sub key1"
     *
     * @param string $option
     * @param mixed $default
     * @return mixed
     */
    public function getOption($option, $default = null, $namespace = 'options')
    {
        $options = $this->getOptions($namespace);
        $optionArr = explode('.', $option);

        $option = $this->getOptionFromArray($options, $optionArr, $default, $option);
        return $option;
    }

    private function getOptionFromArray($options, array $option, $default, $origOption)
    {
        $currOption = array_shift($option);
        //we need this fix to accept both array/ZendConfig -- there is know problem with offsetExists() in PHP
        //if(array_key_exists($currOption, $options)) {
        if(array_key_exists($currOption, $options) || ($options instanceof Config && $options->offsetExists($currOption))) {
            if(count($option) >= 1) {
                return $this->getOptionFromArray($options[$currOption], $option, $default, $origOption);
            }

            return $options[$currOption];
        }

        if($default !== null) {
            return $default;
        }

        throw new InvalidArgumentException("Option '$origOption' is not set");
    }

}

<MSG> application event identifier changed to Zend\Mvc\Application

<DFF> @@ -23,7 +23,7 @@ abstract class AbstractModule implements
     {
         $sharedManager = $moduleManager->getEventManager()->getSharedManager();
         $instance = $this;//TODO this will no be needed in PHP 5.4
-        $sharedManager->attach('application', 'bootstrap', function($e) use ($instance, $moduleManager) {
+        $sharedManager->attach('Zend\Mvc\Application', 'bootstrap', function($e) use ($instance, $moduleManager) {
             $app = $e->getParam('application');
             $instance->setMergedConfig($app->getConfig());
             $instance->bootstrap($moduleManager, $app);

{'commit': "diff --git a/src/ZfcBase/Module/AbstractModule.php b/src/ZfcBase/Module/AbstractModule.php\nindex 236dc2d..1f3d49f 100644\n--- a/src/ZfcBase/Module/AbstractModule.php\n+++ b/src/ZfcBase/Module/AbstractModule.php\n@@ -23,7 +23,7 @@ abstract class AbstractModule implements\n     {\n         $sharedManager = $moduleManager->getEventManager()->getSharedManager();\n         $instance = $this;//TODO this will no be needed in PHP 5.4\n-        $sharedManager->attach('application', 'bootstrap', function($e) use ($instance, $moduleManager) {\n+        $sharedManager->attach('Zend\\Mvc\\Application', 'bootstrap', function($e) use ($instance, $moduleManager) {\n             $app = $e->getParam('application');\n             $instance->setMergedConfig($app->getConfig());\n             $instance->bootstrap($moduleManager, $app);\n", 'commit_subject': 'application event identifier changed to Zend\\Mvc\\Application', 'repo_name': 'ZF-Commons/ZfcBase', 'committer': {'name': 'Aleksey Khudyakov', 'email': '0506dd4514c9f6c9ad1fdd010edaaa1d5f0d3af2@xerkus.pro', 'time_sec': '1347632945', 'tz_offset': '660', 'date': {'seconds': '1347632945'}}, 'commit_tree': 'd38023a945ca70ef7565249ff23792e4d7e4896c', 'commit_message': 'application event identifier changed to Zend\\Mvc\\Application\n', 'language_name': 'PHP', 'license': 'bsd-3-clause', 'hunks': "@@ -23,7 +23,7 @@ abstract class AbstractModule implements\n     {\n         $sharedManager = $moduleManager->getEventManager()->getSharedManager();\n         $instance = $this;//TODO this will no be needed in PHP 5.4\n-        $sharedManager->attach('application', 'bootstrap', function($e) use ($instance, $moduleManager) {\n+        $sharedManager->attach('Zend\\Mvc\\Application', 'bootstrap', function($e) use ($instance, $moduleManager) {\n             $app = $e->getParam('application');\n             $instance->setMergedConfig($app->getConfig());\n             $instance->bootstrap($moduleManager, $app);\n", 'addition_count': 1, 'deletion_count': 1, 'src_file': 'a/src/ZfcBase/Module/AbstractModule.php', 'tgt_file': 'b/src/ZfcBase/Module/AbstractModule.php', 'file_extension': '.php', 'before_file': '<?php\n\nnamespace ZfcBase\\Module;\n\nuse InvalidArgumentException;\nuse Zend\\Config\\Config;\nuse Zend\\EventManager\\EventInterface as Event;\nuse Zend\\EventManager\\StaticEventManager;\nuse Zend\\ModuleManager\\Feature\\AutoloaderProviderInterface;\nuse Zend\\ModuleManager\\Feature\\LocatorRegisteredInterface;\nuse Zend\\ModuleManager\\ModuleManager;\nuse Zend\\Mvc\\ApplicationInterface;\n\nabstract class AbstractModule implements\n    AutoloaderProviderInterface,\n    LocatorRegisteredInterface\n{\n    protected $mergedConfig;\n\n    abstract public function getDir();\n    abstract public function getNamespace();\n\n    {\n        $sharedManager = $moduleManager->getEventManager()->getSharedManager();\n        $instance = $this;//TODO this will no be needed in PHP 5.4\n        $sharedManager->attach(\'application\', \'bootstrap\', function($e) use ($instance, $moduleManager) {\n            $app = $e->getParam(\'application\');\n            $instance->setMergedConfig($app->getConfig());\n            $instance->bootstrap($moduleManager, $app);\n            $instance->bootstrap($moduleManager, $app);\n        });\n    }\n\n    public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $app)\n    {\n    }\n\n    public function getAutoloaderConfig()\n    {\n        return array(\n            \'Zend\\Loader\\ClassMapAutoloader\' => array(\n                $this->getDir() . \'/autoload_classmap.php\',\n            ),\n            \'Zend\\Loader\\StandardAutoloader\' => array(\n                \'namespaces\' => array(\n                    $this->getNamespace() => $this->getDir() . \'/src/\' . $this->getNamespace(),\n                ),\n            ),\n        );\n    }\n\n    public function getConfig()\n    {\n        return include $this->getDir() . \'/config/module.config.php\';\n    }\n\n    public function getMergedConfig()\n    {\n        return $this->mergedConfig;\n    }\n\n    public function setMergedConfig($mergedConfig)\n    {\n        $this->mergedConfig = $mergedConfig;\n    }\n\n    public function getOptions($namespace = \'options\')\n    {\n        $config = $this->getMergedConfig();\n        if(empty($config[$this->getNamespace()][$namespace])) {\n            return array();\n        }\n\n        if (is_array($config[$this->getNamespace()][$namespace])) {\n            return $config[$this->getNamespace()][$namespace];\n        } else {\n            return $config[$this->getNamespace()][$namespace]->toArray();\n        }\n    }\n\n    /**\n     * Returns module option value.\n     * Dot character is used to separate sub arrays.\n     *\n     * Example:\n     * array(\n     *      \'option1\' => \'this is my option 1\'\n     *      \'option2\' => array(\n     *          \'key1\' => \'sub key1\',\n     *          \'key2\' => \'sub key2\',\n     *      )\n     * )\n     *\n     * $module->getOption(\'option1\');\n     * Returns: (string) "This is my option 1"\n     *\n     * $module->getOption(\'option2\');\n     * Returns: array(\n     *          \'key1\' => \'sub key1\',\n     *          \'key2\' => \'sub key2\',\n     *      )\n     *\n     * $module->getOption(\'option2.key1\');\n     * Returns: (string) "sub key1"\n     *\n     * @param string $option\n     * @param mixed $default\n     * @return mixed\n     */\n    public function getOption($option, $default = null, $namespace = \'options\')\n    {\n        $options = $this->getOptions($namespace);\n        $optionArr = explode(\'.\', $option);\n\n        $option = $this->getOptionFromArray($options, $optionArr, $default, $option);\n        return $option;\n    }\n\n    private function getOptionFromArray($options, array $option, $default, $origOption)\n    {\n        $currOption = array_shift($option);\n        //we need this fix to accept both array/ZendConfig -- there is know problem with offsetExists() in PHP\n        //if(array_key_exists($currOption, $options)) {\n        if(array_key_exists($currOption, $options) || ($options instanceof Config && $options->offsetExists($currOption))) {\n            if(count($option) >= 1) {\n                return $this->getOptionFromArray($options[$currOption], $option, $default, $origOption);\n            }\n\n            return $options[$currOption];\n        }\n\n        if($default !== null) {\n            return $default;\n        }\n\n        throw new InvalidArgumentException("Option \'$origOption\' is not set");\n    }\n\n}\n', 'message': 'application event identifier changed to Zend\\Mvc\\Application\n', 'author_name': 'Aleksey Khudyakov', 'lang': 'php'}