|
|
@@ -56,6 +56,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
protected $_environment;
|
|
|
|
|
|
/**
|
|
|
+ * Flattened (lowercase) option keys used for lookups
|
|
|
+ *
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ protected $_optionKeys = array();
|
|
|
+
|
|
|
+ /**
|
|
|
* @var array
|
|
|
*/
|
|
|
protected $_options = array();
|
|
|
@@ -105,7 +112,11 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
*/
|
|
|
public function setOptions(array $options)
|
|
|
{
|
|
|
+ $this->_options = $this->mergeOptions($this->_options, $options);
|
|
|
+
|
|
|
$options = array_change_key_case($options, CASE_LOWER);
|
|
|
+ $this->_optionKeys = array_keys($options);
|
|
|
+
|
|
|
$methods = get_class_methods($this);
|
|
|
foreach ($methods as $key => $method) {
|
|
|
$methods[$key] = strtolower($method);
|
|
|
@@ -117,7 +128,6 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
foreach ($options['pluginpaths'] as $prefix => $path) {
|
|
|
$pluginLoader->addPrefixPath($prefix, $path);
|
|
|
}
|
|
|
-
|
|
|
unset($options['pluginpaths']);
|
|
|
}
|
|
|
|
|
|
@@ -132,7 +142,6 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- $this->_options = $this->mergeOptions($this->_options, $options);
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
@@ -154,7 +163,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
*/
|
|
|
public function hasOption($key)
|
|
|
{
|
|
|
- return array_key_exists($key, $this->_options);
|
|
|
+ return in_array($key, $this->_optionKeys);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -166,7 +175,9 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
public function getOption($key)
|
|
|
{
|
|
|
if ($this->hasOption($key)) {
|
|
|
- return $this->_options[$key];
|
|
|
+ $options = $this->getOptions();
|
|
|
+ $options = array_change_key_case($options, CASE_LOWER);
|
|
|
+ return $options[strtolower($key)];
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
@@ -249,13 +260,6 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
*/
|
|
|
public function registerPluginResource($resource, $options = null)
|
|
|
{
|
|
|
- /*
|
|
|
- if (is_string($resource) && class_exists($resource)) {
|
|
|
- $options = (array) $options;
|
|
|
- $options['bootstrap'] = $this;
|
|
|
- $resource = new $resource($options);
|
|
|
- }
|
|
|
- */
|
|
|
if ($resource instanceof Zend_Application_Resource_Resource) {
|
|
|
$resource->setBootstrap($this);
|
|
|
$pluginName = $this->_resolvePluginResourceName($resource);
|
|
|
@@ -267,7 +271,6 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
throw new Zend_Application_Bootstrap_Exception('Invalid resource provided to ' . __METHOD__);
|
|
|
}
|
|
|
|
|
|
- // $resource = strtolower($resource);
|
|
|
$this->_pluginResources[$resource] = $options;
|
|
|
return $this;
|
|
|
}
|
|
|
@@ -342,14 +345,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (false !== $pluginName = $this->_loadPluginResource($plugin, $spec)) {
|
|
|
if (0 === strcasecmp($resource, $pluginName)) {
|
|
|
return $this->_pluginResources[$pluginName];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (class_exists($plugin, false)) {
|
|
|
+ if (class_exists($plugin)) {
|
|
|
$spec = (array) $spec;
|
|
|
$spec['bootstrap'] = $this;
|
|
|
$instance = new $plugin($spec);
|
|
|
@@ -643,40 +645,40 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
|
|
*/
|
|
|
protected function _executeResource($resource)
|
|
|
{
|
|
|
- $resource = strtolower($resource);
|
|
|
+ $resourceName = strtolower($resource);
|
|
|
|
|
|
- if (in_array($resource, $this->_run)) {
|
|
|
+ if (in_array($resourceName, $this->_run)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (isset($this->_started[$resource]) && $this->_started[$resource]) {
|
|
|
+ if (isset($this->_started[$resourceName]) && $this->_started[$resourceName]) {
|
|
|
throw new Zend_Application_Bootstrap_Exception('Circular resource dependency detected');
|
|
|
}
|
|
|
|
|
|
$classResources = $this->getClassResources();
|
|
|
- if (array_key_exists($resource, $classResources)) {
|
|
|
- $this->_started[$resource] = true;
|
|
|
- $method = $classResources[$resource];
|
|
|
+ if (array_key_exists($resourceName, $classResources)) {
|
|
|
+ $this->_started[$resourceName] = true;
|
|
|
+ $method = $classResources[$resourceName];
|
|
|
$return = $this->$method();
|
|
|
- unset($this->_started[$resource]);
|
|
|
+ unset($this->_started[$resourceName]);
|
|
|
$this->_markRun($resource);
|
|
|
|
|
|
if (null !== $return) {
|
|
|
- $this->getContainer()->{$resource} = $return;
|
|
|
+ $this->getContainer()->{$resourceName} = $return;
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if ($this->hasPluginResource($resource)) {
|
|
|
- $this->_started[$resource] = true;
|
|
|
+ $this->_started[$resourceName] = true;
|
|
|
$plugin = $this->getPluginResource($resource);
|
|
|
$return = $plugin->init();
|
|
|
- unset($this->_started[$resource]);
|
|
|
- $this->_markRun($resource);
|
|
|
+ unset($this->_started[$resourceName]);
|
|
|
+ $this->_markRun($resourceName);
|
|
|
|
|
|
if (null !== $return) {
|
|
|
- $this->getContainer()->{$resource} = $return;
|
|
|
+ $this->getContainer()->{$resourceName} = $return;
|
|
|
}
|
|
|
|
|
|
return;
|