Ver Fonte

ZF-6567: module bootstrap should inherit application bootstrap

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15515 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew há 16 anos atrás
pai
commit
eada866631

+ 5 - 1
library/Zend/Application/Module/Bootstrap.php

@@ -53,6 +53,11 @@ abstract class Zend_Application_Module_Bootstrap
     {
         parent::__construct($application);
 
+        // Use same plugin loader as parent bootstrap
+        if ($application instanceof Zend_Application_Bootstrap_ResourceBootstrapper) {
+            $this->setPluginLoader($application->getPluginLoader());
+        }
+
         $key = strtolower($this->getModuleName());
         if ($application->hasOption($key)) {
             // Don't run via setOptions() to prevent duplicate initialization
@@ -64,7 +69,6 @@ abstract class Zend_Application_Module_Bootstrap
                 'resourceloader' => $application->getOption('resourceloader')
             ));
         }
-
         $this->initResourceLoader();
 
         // ZF-6545: prevent recursive registration of modules

+ 32 - 0
tests/Zend/Application/Module/BootstrapTest.php

@@ -189,6 +189,38 @@ class Zend_Application_Module_BootstrapTest extends PHPUnit_Framework_TestCase
             $this->assertFalse($bootstrap->hasPluginResource('Modules'), var_export($resources, 1));
         }
     }
+
+    /**
+     * @group ZF-6567
+     */
+    public function testModuleBootstrapShouldInheritApplicationBootstrapPluginPaths()
+    {
+        require_once dirname(__FILE__) . '/../_files/ZfModuleBootstrap.php';
+        $this->application->setOptions(array(
+            'resources' => array(
+                'modules' => array(),
+                'frontController' => array(
+                    'baseUrl'             => '/foo',
+                    'moduleDirectory'     => dirname(__FILE__) . '/../_files/modules',
+                ),
+            ),
+            'pluginPaths' => array(
+                'ZfModuleBootstrap_Resource' => dirname(__FILE__),
+            ),
+            'bootstrap' => array(
+                'path'  => dirname(__FILE__) . '/../_files/ZfAppBootstrap.php',
+                'class' => 'ZfAppBootstrap',
+            )
+        ));
+        $appBootstrap = $this->application->getBootstrap();
+        $appBootstrap->bootstrap('Modules');
+        $modules = $appBootstrap->getResource('Modules');
+        foreach ($modules as $bootstrap) {
+            $loader = $bootstrap->getPluginLoader();
+            $paths  = $loader->getPaths();
+            $this->assertTrue(array_key_exists('ZfModuleBootstrap_Resource_', $paths));
+        }
+    }
 }
 
 if (PHPUnit_MAIN_METHOD == 'Zend_Application_Module_BootstrapTest::main') {