web/lib/Zend/Application/Resource/Modules.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Application
    16  * @package    Zend_Application
    17  * @subpackage Resource
    17  * @subpackage Resource
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Modules.php 20814 2010-02-01 20:13:08Z freak $
    20  * @version    $Id: Modules.php 24593 2012-01-05 20:35:02Z matthew $
    21  */
    21  */
    22 
    22 
    23 /**
    23 /**
    24  * @see Zend_Application_Resource_ResourceAbstract
    24  * @see Zend_Application_Resource_ResourceAbstract
    25  */
    25  */
    30  * Module bootstrapping resource
    30  * Module bootstrapping resource
    31  *
    31  *
    32  * @category   Zend
    32  * @category   Zend
    33  * @package    Zend_Application
    33  * @package    Zend_Application
    34  * @subpackage Resource
    34  * @subpackage Resource
    35  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    35  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    36  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    36  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    37  */
    37  */
    38 class Zend_Application_Resource_Modules extends Zend_Application_Resource_ResourceAbstract
    38 class Zend_Application_Resource_Modules extends Zend_Application_Resource_ResourceAbstract
    39 {
    39 {
    40     /**
    40     /**
    60      * @return array
    60      * @return array
    61      * @throws Zend_Application_Resource_Exception When bootstrap class was not found
    61      * @throws Zend_Application_Resource_Exception When bootstrap class was not found
    62      */
    62      */
    63     public function init()
    63     public function init()
    64     {
    64     {
       
    65         $bootstraps = array();
    65         $bootstrap = $this->getBootstrap();
    66         $bootstrap = $this->getBootstrap();
    66         $bootstrap->bootstrap('FrontController');
    67         $bootstrap->bootstrap('FrontController');
    67         $front = $bootstrap->getResource('FrontController');
    68         $front = $bootstrap->getResource('FrontController');
    68 
    69 
    69         $modules = $front->getControllerDirectory();
    70         $modules = $front->getControllerDirectory();
   101                 // If the found bootstrap class matches the one calling this
   102                 // If the found bootstrap class matches the one calling this
   102                 // resource, don't re-execute.
   103                 // resource, don't re-execute.
   103                 continue;
   104                 continue;
   104             }
   105             }
   105 
   106 
       
   107             $bootstraps[$module] = $bootstrapClass;
       
   108         }
       
   109 
       
   110         return $this->_bootstraps = $this->bootstrapBootstraps($bootstraps);
       
   111     }
       
   112 
       
   113     /*
       
   114      * Bootstraps the bootstraps found. Allows for easy extension.
       
   115      * @param array $bootstraps Array containing the bootstraps to instantiate
       
   116      */
       
   117     protected function bootstrapBootstraps($bootstraps)
       
   118     {
       
   119         $bootstrap = $this->getBootstrap();
       
   120         $out = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
       
   121 
       
   122         foreach($bootstraps as $module => $bootstrapClass) {
   106             $moduleBootstrap = new $bootstrapClass($bootstrap);
   123             $moduleBootstrap = new $bootstrapClass($bootstrap);
   107             $moduleBootstrap->bootstrap();
   124             $moduleBootstrap->bootstrap();
   108             $this->_bootstraps[$module] = $moduleBootstrap;
   125             $out[$module] = $moduleBootstrap;
   109         }
   126         }
   110 
   127 
   111         return $this->_bootstraps;
   128         return $out;
   112     }
   129     }
   113 
   130 
   114     /**
   131     /**
   115      * Get bootstraps that have been run
   132      * Get bootstraps that have been run
   116      *
   133      *