equal
deleted
inserted
replaced
12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
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 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: Application.php 25024 2012-07-30 15:08:15Z rob $ |
19 * @version $Id$ |
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * @category Zend |
23 * @category Zend |
24 * @package Zend_Application |
24 * @package Zend_Application |
25 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
25 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
26 * @license http://framework.zend.com/license/new-bsd New BSD License |
26 * @license http://framework.zend.com/license/new-bsd New BSD License |
27 */ |
27 */ |
28 class Zend_Application |
28 class Zend_Application |
29 { |
29 { |
30 /** |
30 /** |
84 if (is_string($options)) { |
84 if (is_string($options)) { |
85 $options = $this->_loadConfig($options); |
85 $options = $this->_loadConfig($options); |
86 } elseif ($options instanceof Zend_Config) { |
86 } elseif ($options instanceof Zend_Config) { |
87 $options = $options->toArray(); |
87 $options = $options->toArray(); |
88 } elseif (!is_array($options)) { |
88 } elseif (!is_array($options)) { |
89 throw new Zend_Application_Exception('Invalid options provided; must be location of config file, a config object, or an array'); |
89 throw new Zend_Application_Exception( |
|
90 'Invalid options provided; must be location of config file,' |
|
91 . ' a config object, or an array' |
|
92 ); |
90 } |
93 } |
91 |
94 |
92 $this->setOptions($options); |
95 $this->setOptions($options); |
93 } |
96 } |
94 } |
97 } |
125 { |
128 { |
126 if (!empty($options['config'])) { |
129 if (!empty($options['config'])) { |
127 if (is_array($options['config'])) { |
130 if (is_array($options['config'])) { |
128 $_options = array(); |
131 $_options = array(); |
129 foreach ($options['config'] as $tmp) { |
132 foreach ($options['config'] as $tmp) { |
130 $_options = $this->mergeOptions($_options, $this->_loadConfig($tmp)); |
133 $_options = $this->mergeOptions( |
|
134 $_options, $this->_loadConfig($tmp) |
|
135 ); |
131 } |
136 } |
132 $options = $this->mergeOptions($_options, $options); |
137 $options = $this->mergeOptions($_options, $options); |
133 } else { |
138 } else { |
134 $options = $this->mergeOptions($this->_loadConfig($options['config']), $options); |
139 $options = $this->mergeOptions( |
|
140 $this->_loadConfig($options['config']), $options |
|
141 ); |
135 } |
142 } |
136 } |
143 } |
137 |
144 |
138 $this->_options = $options; |
145 $this->_options = $options; |
139 |
146 |
169 |
176 |
170 if (is_string($bootstrap)) { |
177 if (is_string($bootstrap)) { |
171 $this->setBootstrap($bootstrap); |
178 $this->setBootstrap($bootstrap); |
172 } elseif (is_array($bootstrap)) { |
179 } elseif (is_array($bootstrap)) { |
173 if (empty($bootstrap['path'])) { |
180 if (empty($bootstrap['path'])) { |
174 throw new Zend_Application_Exception('No bootstrap path provided'); |
181 throw new Zend_Application_Exception( |
|
182 'No bootstrap path provided' |
|
183 ); |
175 } |
184 } |
176 |
185 |
177 $path = $bootstrap['path']; |
186 $path = $bootstrap['path']; |
178 $class = null; |
187 $class = null; |
179 |
188 |
181 $class = $bootstrap['class']; |
190 $class = $bootstrap['class']; |
182 } |
191 } |
183 |
192 |
184 $this->setBootstrap($path, $class); |
193 $this->setBootstrap($path, $class); |
185 } else { |
194 } else { |
186 throw new Zend_Application_Exception('Invalid bootstrap information provided'); |
195 throw new Zend_Application_Exception( |
|
196 'Invalid bootstrap information provided' |
|
197 ); |
187 } |
198 } |
188 } |
199 } |
189 |
200 |
190 return $this; |
201 return $this; |
191 } |
202 } |
317 } |
328 } |
318 |
329 |
319 if (!class_exists($class, false)) { |
330 if (!class_exists($class, false)) { |
320 require_once $path; |
331 require_once $path; |
321 if (!class_exists($class, false)) { |
332 if (!class_exists($class, false)) { |
322 throw new Zend_Application_Exception('Bootstrap class not found'); |
333 throw new Zend_Application_Exception( |
|
334 'Bootstrap class not found' |
|
335 ); |
323 } |
336 } |
324 } |
337 } |
325 $this->_bootstrap = new $class($this); |
338 $this->_bootstrap = new $class($this); |
326 |
339 |
327 if (!$this->_bootstrap instanceof Zend_Application_Bootstrap_Bootstrapper) { |
340 if (!$this->_bootstrap instanceof Zend_Application_Bootstrap_Bootstrapper) { |
328 throw new Zend_Application_Exception('Bootstrap class does not implement Zend_Application_Bootstrap_Bootstrapper'); |
341 throw new Zend_Application_Exception( |
|
342 'Bootstrap class does not implement' |
|
343 . ' Zend_Application_Bootstrap_Bootstrapper' |
|
344 ); |
329 } |
345 } |
330 |
346 |
331 return $this; |
347 return $this; |
332 } |
348 } |
333 |
349 |
401 |
417 |
402 case 'php': |
418 case 'php': |
403 case 'inc': |
419 case 'inc': |
404 $config = include $file; |
420 $config = include $file; |
405 if (!is_array($config)) { |
421 if (!is_array($config)) { |
406 throw new Zend_Application_Exception('Invalid configuration file provided; PHP file does not return array value'); |
422 throw new Zend_Application_Exception( |
|
423 'Invalid configuration file provided; PHP file does not' |
|
424 . ' return array value' |
|
425 ); |
407 } |
426 } |
408 return $config; |
427 return $config; |
409 break; |
428 break; |
410 |
429 |
411 default: |
430 default: |
412 throw new Zend_Application_Exception('Invalid configuration file provided; unknown config type'); |
431 throw new Zend_Application_Exception( |
|
432 'Invalid configuration file provided; unknown config type' |
|
433 ); |
413 } |
434 } |
414 |
435 |
415 return $config->toArray(); |
436 return $config->toArray(); |
416 } |
437 } |
417 } |
438 } |