import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Bootstrap
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: BootstrapAbstract.php 17802 2009-08-24 21:15:12Z matthew $
|
||||
* @version $Id: BootstrapAbstract.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -32,7 +32,7 @@
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
implements Zend_Application_Bootstrap_Bootstrapper,
|
||||
implements Zend_Application_Bootstrap_Bootstrapper,
|
||||
Zend_Application_Bootstrap_ResourceBootstrapper
|
||||
{
|
||||
/**
|
||||
@ -57,7 +57,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Flattened (lowercase) option keys used for lookups
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_optionKeys = array();
|
||||
@ -90,12 +90,12 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Sets application object, initializes options, and prepares list of
|
||||
* Sets application object, initializes options, and prepares list of
|
||||
* initializer methods.
|
||||
*
|
||||
*
|
||||
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
|
||||
* @return void
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid applicaiton is provided
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid applicaiton is provided
|
||||
*/
|
||||
public function __construct($application)
|
||||
{
|
||||
@ -106,8 +106,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Set class state
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
@ -115,7 +115,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
$this->_options = $this->mergeOptions($this->_options, $options);
|
||||
|
||||
$options = array_change_key_case($options, CASE_LOWER);
|
||||
$this->_optionKeys = array_keys($options);
|
||||
$this->_optionKeys = array_merge($this->_optionKeys, array_keys($options));
|
||||
|
||||
$methods = get_class_methods($this);
|
||||
foreach ($methods as $key => $method) {
|
||||
@ -124,7 +124,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
if (array_key_exists('pluginpaths', $options)) {
|
||||
$pluginLoader = $this->getPluginLoader();
|
||||
|
||||
|
||||
foreach ($options['pluginpaths'] as $prefix => $path) {
|
||||
$pluginLoader->addPrefixPath($prefix, $path);
|
||||
}
|
||||
@ -147,7 +147,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Get current options from bootstrap
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
@ -157,8 +157,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Is an option present?
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOption($key)
|
||||
@ -168,8 +168,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Retrieve a single option
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOption($key)
|
||||
@ -184,9 +184,9 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Merge options recursively
|
||||
*
|
||||
* @param array $array1
|
||||
* @param mixed $array2
|
||||
*
|
||||
* @param array $array1
|
||||
* @param mixed $array2
|
||||
* @return array
|
||||
*/
|
||||
public function mergeOptions(array $array1, $array2 = null)
|
||||
@ -195,7 +195,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
foreach ($array2 as $key => $val) {
|
||||
if (is_array($array2[$key])) {
|
||||
$array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
|
||||
? $this->mergeOptions($array1[$key], $array2[$key])
|
||||
? $this->mergeOptions($array1[$key], $array2[$key])
|
||||
: $array2[$key];
|
||||
} else {
|
||||
$array1[$key] = $val;
|
||||
@ -207,10 +207,10 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Get class resources (as resource/method pairs)
|
||||
*
|
||||
*
|
||||
* Uses get_class_methods() by default, reflection on prior to 5.2.6,
|
||||
* as a bug prevents the usage of get_class_methods() there.
|
||||
*
|
||||
* as a bug prevents the usage of get_class_methods() there.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClassResources()
|
||||
@ -220,14 +220,14 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
$class = new ReflectionObject($this);
|
||||
$classMethods = $class->getMethods();
|
||||
$methodNames = array();
|
||||
|
||||
|
||||
foreach ($classMethods as $method) {
|
||||
$methodNames[] = $method->getName();
|
||||
}
|
||||
} else {
|
||||
$methodNames = get_class_methods($this);
|
||||
}
|
||||
|
||||
|
||||
$this->_classResources = array();
|
||||
foreach ($methodNames as $method) {
|
||||
if (5 < strlen($method) && '_init' === substr($method, 0, 5)) {
|
||||
@ -235,13 +235,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->_classResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class resource names
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClassResourceNames()
|
||||
@ -252,7 +252,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Register a new resource plugin
|
||||
*
|
||||
*
|
||||
* @param string|Zend_Application_Resource_Resource $resource
|
||||
* @param mixed $options
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
@ -277,8 +277,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Unregister a resource from the bootstrap
|
||||
*
|
||||
* @param string|Zend_Application_Resource_Resource $resource
|
||||
*
|
||||
* @param string|Zend_Application_Resource_Resource $resource
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
* @throws Zend_Application_Bootstrap_Exception When unknown resource type is provided
|
||||
*/
|
||||
@ -304,16 +304,16 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the requested plugin resource registered?
|
||||
*
|
||||
* @param string $resource
|
||||
* Is the requested plugin resource registered?
|
||||
*
|
||||
* @param string $resource
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPluginResource($resource)
|
||||
{
|
||||
return (null !== $this->getPluginResource($resource));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a registered plugin resource
|
||||
*
|
||||
@ -365,12 +365,12 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all plugin resources
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPluginResources()
|
||||
@ -383,7 +383,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Retrieve plugin resource names
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPluginResourceNames()
|
||||
@ -394,8 +394,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Set plugin loader for loading resources
|
||||
*
|
||||
* @param Zend_Loader_PluginLoader_Interface $loader
|
||||
*
|
||||
* @param Zend_Loader_PluginLoader_Interface $loader
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
public function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader)
|
||||
@ -403,7 +403,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
$this->_pluginLoader = $loader;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plugin loader for resources
|
||||
*
|
||||
@ -424,13 +424,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Set application/parent bootstrap
|
||||
*
|
||||
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
|
||||
*
|
||||
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
public function setApplication($application)
|
||||
{
|
||||
if (($application instanceof Zend_Application)
|
||||
if (($application instanceof Zend_Application)
|
||||
|| ($application instanceof Zend_Application_Bootstrap_Bootstrapper)
|
||||
) {
|
||||
$this->_application = $application;
|
||||
@ -439,10 +439,10 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve parent application instance
|
||||
*
|
||||
*
|
||||
* @return Zend_Application|Zend_Application_Bootstrap_Bootstrapper
|
||||
*/
|
||||
public function getApplication()
|
||||
@ -452,7 +452,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Retrieve application environment
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnvironment()
|
||||
@ -466,13 +466,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
/**
|
||||
* Set resource container
|
||||
*
|
||||
* By default, if a resource callback has a non-null return value, this
|
||||
* value will be stored in a container using the resource name as the
|
||||
* By default, if a resource callback has a non-null return value, this
|
||||
* value will be stored in a container using the resource name as the
|
||||
* key.
|
||||
*
|
||||
* Containers must be objects, and must allow setting public properties.
|
||||
*
|
||||
* @param object $container
|
||||
*
|
||||
* @param object $container
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
public function setContainer($container)
|
||||
@ -486,7 +486,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Retrieve resource container
|
||||
*
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getContainer()
|
||||
@ -500,11 +500,11 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
/**
|
||||
* Determine if a resource has been stored in the container
|
||||
*
|
||||
* During bootstrap resource initialization, you may return a value. If
|
||||
* During bootstrap resource initialization, you may return a value. If
|
||||
* you do, it will be stored in the {@link setContainer() container}.
|
||||
* You can use this method to determine if a value was stored.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasResource($name)
|
||||
@ -517,13 +517,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
/**
|
||||
* Retrieve a resource from the container
|
||||
*
|
||||
* During bootstrap resource initialization, you may return a value. If
|
||||
* During bootstrap resource initialization, you may return a value. If
|
||||
* you do, it will be stored in the {@link setContainer() container}.
|
||||
* You can use this method to retrieve that value.
|
||||
*
|
||||
* If no value was returned, this will return a null value.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @param string $name
|
||||
* @return null|mixed
|
||||
*/
|
||||
public function getResource($name)
|
||||
@ -551,7 +551,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
/**
|
||||
* Implement PHP's magic to ask for the
|
||||
* existence of a ressource in the bootstrap
|
||||
*
|
||||
*
|
||||
* @param string $prop
|
||||
* @return bool
|
||||
*/
|
||||
@ -567,12 +567,12 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
* child class 'Bootstrap' (in which case, overriding this method
|
||||
* would result in it being treated as a constructor).
|
||||
*
|
||||
* If you need to override this functionality, override the
|
||||
* If you need to override this functionality, override the
|
||||
* {@link _bootstrap()} method.
|
||||
*
|
||||
*
|
||||
* @param null|string|array $resource
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
|
||||
*/
|
||||
final public function bootstrap($resource = null)
|
||||
{
|
||||
@ -582,11 +582,11 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Overloading: intercept calls to bootstrap<resourcename>() methods
|
||||
*
|
||||
* @param string $method
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
* @return void
|
||||
* @throws Zend_Application_Bootstrap_Exception On invalid method name
|
||||
* @throws Zend_Application_Bootstrap_Exception On invalid method name
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
@ -601,12 +601,12 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
/**
|
||||
* Bootstrap implementation
|
||||
*
|
||||
* This method may be overridden to provide custom bootstrapping logic.
|
||||
* This method may be overridden to provide custom bootstrapping logic.
|
||||
* It is the sole method called by {@link bootstrap()}.
|
||||
*
|
||||
* @param null|string|array $resource
|
||||
*
|
||||
* @param null|string|array $resource
|
||||
* @return void
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
|
||||
*/
|
||||
protected function _bootstrap($resource = null)
|
||||
{
|
||||
@ -614,7 +614,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
foreach ($this->getClassResourceNames() as $resource) {
|
||||
$this->_executeResource($resource);
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->getPluginResourceNames() as $resource) {
|
||||
$this->_executeResource($resource);
|
||||
}
|
||||
@ -632,14 +632,14 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
/**
|
||||
* Execute a resource
|
||||
*
|
||||
* Checks to see if the resource has already been run. If not, it searches
|
||||
* first to see if a local method matches the resource, and executes that.
|
||||
* If not, it checks to see if a plugin resource matches, and executes that
|
||||
* Checks to see if the resource has already been run. If not, it searches
|
||||
* first to see if a local method matches the resource, and executes that.
|
||||
* If not, it checks to see if a plugin resource matches, and executes that
|
||||
* if found.
|
||||
*
|
||||
* Finally, if not found, it throws an exception.
|
||||
*
|
||||
* @param string $resource
|
||||
* @param string $resource
|
||||
* @return void
|
||||
* @throws Zend_Application_Bootstrap_Exception When resource not found
|
||||
*/
|
||||
@ -661,7 +661,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
$method = $classResources[$resourceName];
|
||||
$return = $this->$method();
|
||||
unset($this->_started[$resourceName]);
|
||||
$this->_markRun($resource);
|
||||
$this->_markRun($resourceName);
|
||||
|
||||
if (null !== $return) {
|
||||
$this->getContainer()->{$resourceName} = $return;
|
||||
@ -689,9 +689,9 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Load a plugin resource
|
||||
*
|
||||
* @param string $resource
|
||||
* @param array|object|null $options
|
||||
*
|
||||
* @param string $resource
|
||||
* @param array|object|null $options
|
||||
* @return string|false
|
||||
*/
|
||||
protected function _loadPluginResource($resource, $options)
|
||||
@ -719,8 +719,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
|
||||
/**
|
||||
* Mark a resource as having run
|
||||
*
|
||||
* @param string $resource
|
||||
*
|
||||
* @param string $resource
|
||||
* @return void
|
||||
*/
|
||||
protected function _markRun($resource)
|
||||
@ -739,8 +739,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
* - class name (if none of the above are true)
|
||||
*
|
||||
* The name is then cast to lowercase.
|
||||
*
|
||||
* @param Zend_Application_Resource_Resource $resource
|
||||
*
|
||||
* @param Zend_Application_Resource_Resource $resource
|
||||
* @return string
|
||||
*/
|
||||
protected function _resolvePluginResourceName($resource)
|
||||
|
Reference in New Issue
Block a user