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-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2015 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 24593 2012-01-05 20:35:02Z matthew $ |
20 * @version $Id$ |
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-2012 Zend Technologies USA Inc. (http://www.zend.com) |
35 * @copyright Copyright (c) 2005-2015 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 /** |
71 $default = $front->getDefaultModule(); |
70 $default = $front->getDefaultModule(); |
72 $curBootstrapClass = get_class($bootstrap); |
71 $curBootstrapClass = get_class($bootstrap); |
73 foreach ($modules as $module => $moduleDirectory) { |
72 foreach ($modules as $module => $moduleDirectory) { |
74 $bootstrapClass = $this->_formatModuleName($module) . '_Bootstrap'; |
73 $bootstrapClass = $this->_formatModuleName($module) . '_Bootstrap'; |
75 if (!class_exists($bootstrapClass, false)) { |
74 if (!class_exists($bootstrapClass, false)) { |
76 $bootstrapPath = dirname($moduleDirectory) . '/Bootstrap.php'; |
75 $bootstrapPath = dirname($moduleDirectory) . '/Bootstrap.php'; |
77 if (file_exists($bootstrapPath)) { |
76 if (file_exists($bootstrapPath)) { |
78 $eMsgTpl = 'Bootstrap file found for module "%s" but bootstrap class "%s" not found'; |
77 $eMsgTpl = 'Bootstrap file found for module "%s" but bootstrap class "%s" not found'; |
79 include_once $bootstrapPath; |
78 include_once $bootstrapPath; |
80 if (($default != $module) |
79 if (($default != $module) |
81 && !class_exists($bootstrapClass, false) |
80 && !class_exists($bootstrapClass, false) |
82 ) { |
81 ) { |
83 throw new Zend_Application_Resource_Exception(sprintf( |
82 throw new Zend_Application_Resource_Exception( |
84 $eMsgTpl, $module, $bootstrapClass |
83 sprintf( |
85 )); |
84 $eMsgTpl, $module, $bootstrapClass |
|
85 ) |
|
86 ); |
86 } elseif ($default == $module) { |
87 } elseif ($default == $module) { |
87 if (!class_exists($bootstrapClass, false)) { |
88 if (!class_exists($bootstrapClass, false)) { |
88 $bootstrapClass = 'Bootstrap'; |
89 $bootstrapClass = 'Bootstrap'; |
89 if (!class_exists($bootstrapClass, false)) { |
90 if (!class_exists($bootstrapClass, false)) { |
90 throw new Zend_Application_Resource_Exception(sprintf( |
91 throw new Zend_Application_Resource_Exception( |
91 $eMsgTpl, $module, $bootstrapClass |
92 sprintf( |
92 )); |
93 $eMsgTpl, $module, $bootstrapClass |
|
94 ) |
|
95 ); |
93 } |
96 } |
94 } |
97 } |
95 } |
98 } |
96 } else { |
99 } else { |
97 continue; |
100 continue; |
115 * @param array $bootstraps Array containing the bootstraps to instantiate |
118 * @param array $bootstraps Array containing the bootstraps to instantiate |
116 */ |
119 */ |
117 protected function bootstrapBootstraps($bootstraps) |
120 protected function bootstrapBootstraps($bootstraps) |
118 { |
121 { |
119 $bootstrap = $this->getBootstrap(); |
122 $bootstrap = $this->getBootstrap(); |
120 $out = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); |
123 $out = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); |
121 |
124 |
122 foreach($bootstraps as $module => $bootstrapClass) { |
125 foreach ($bootstraps as $module => $bootstrapClass) { |
123 $moduleBootstrap = new $bootstrapClass($bootstrap); |
126 $moduleBootstrap = new $bootstrapClass($bootstrap); |
124 $moduleBootstrap->bootstrap(); |
127 $moduleBootstrap->bootstrap(); |
125 $out[$module] = $moduleBootstrap; |
128 $out[$module] = $moduleBootstrap; |
126 } |
129 } |
127 |
130 |