web/lib/Zend/Tool/Framework/Loader/BasicLoader.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_Tool
    16  * @package    Zend_Tool
    17  * @subpackage Framework
    17  * @subpackage Framework
    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: BasicLoader.php 20785 2010-01-31 09:43:03Z mikaelkael $
    20  * @version    $Id: BasicLoader.php 24593 2012-01-05 20:35:02Z matthew $
    21  */
    21  */
    22 
    22 
    23 /**
    23 /**
    24  * @see Zend_Tool_Framework_Loader_Abstract
    24  * @see Zend_Tool_Framework_Loader_Abstract
    25  */
    25  */
    38 require_once 'Zend/Tool/Framework/Provider/Interface.php';
    38 require_once 'Zend/Tool/Framework/Provider/Interface.php';
    39 
    39 
    40 /**
    40 /**
    41  * @category   Zend
    41  * @category   Zend
    42  * @package    Zend_Tool
    42  * @package    Zend_Tool
    43  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    43  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    44  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    44  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    45  */
    45  */
    46 class Zend_Tool_Framework_Loader_BasicLoader 
    46 class Zend_Tool_Framework_Loader_BasicLoader
    47     implements Zend_Tool_Framework_Loader_Interface, Zend_Tool_Framework_Registry_EnabledInterface
    47     implements Zend_Tool_Framework_Loader_Interface, Zend_Tool_Framework_Registry_EnabledInterface
    48 {
    48 {
    49     /**
    49     /**
    50      * @var Zend_Tool_Framework_Repository_Interface
    50      * @var Zend_Tool_Framework_Repository_Interface
    51      */
    51      */
    53 
    53 
    54     /**
    54     /**
    55      * @var array
    55      * @var array
    56      */
    56      */
    57     protected $_classesToLoad = array();
    57     protected $_classesToLoad = array();
    58     
    58 
    59     public function __construct($options = array())
    59     public function __construct($options = array())
    60     {
    60     {
    61         if ($options) {
    61         if ($options) {
    62             $this->setOptions($options);
    62             $this->setOptions($options);
    63         }
    63         }
    64     }
    64     }
    65     
    65 
    66     public function setOptions(Array $options)
    66     public function setOptions(Array $options)
    67     {
    67     {
    68         foreach ($options as $optionName => $optionValue) {
    68         foreach ($options as $optionName => $optionValue) {
    69             $setMethod = 'set' . $optionName;
    69             $setMethod = 'set' . $optionName;
    70             if (method_exists($this, $setMethod)) {
    70             if (method_exists($this, $setMethod)) {
    71                 $this->{$setMethod}($optionValue);
    71                 $this->{$setMethod}($optionValue);
    72             }
    72             }
    73         }
    73         }
    74     }
    74     }
    75     
    75 
    76     /**
    76     /**
    77      * setRegistry() - required by the enabled interface to get an instance of
    77      * setRegistry() - required by the enabled interface to get an instance of
    78      * the registry
    78      * the registry
    79      *
    79      *
    80      * @param Zend_Tool_Framework_Registry_Interface $registry
    80      * @param Zend_Tool_Framework_Registry_Interface $registry
    93     public function setClassesToLoad(array $classesToLoad)
    93     public function setClassesToLoad(array $classesToLoad)
    94     {
    94     {
    95         $this->_classesToLoad = $classesToLoad;
    95         $this->_classesToLoad = $classesToLoad;
    96         return $this;
    96         return $this;
    97     }
    97     }
    98     
    98 
    99     public function load()
    99     public function load()
   100     {
   100     {
   101         $manifestRegistry = $this->_registry->getManifestRepository();
   101         $manifestRegistry = $this->_registry->getManifestRepository();
   102         $providerRegistry = $this->_registry->getProviderRepository();
   102         $providerRegistry = $this->_registry->getProviderRepository();
   103         
   103 
   104         $loadedClasses = array();
   104         $loadedClasses = array();
   105         
   105 
   106         // loop through the loaded classes and ensure that
   106         // loop through the loaded classes and ensure that
   107         foreach ($this->_classesToLoad as $class) {
   107         foreach ($this->_classesToLoad as $class) {
   108             
   108 
   109             if (!class_exists($class)) {
   109             if (!class_exists($class)) {
   110                 Zend_Loader::loadClass($class);
   110                 Zend_Loader::loadClass($class);
   111             }
   111             }
   112 
   112 
   113             // reflect class to see if its something we want to load
   113             // reflect class to see if its something we want to load
   151             $reflectionClass->implementsInterface('Zend_Tool_Framework_Provider_Interface')
   151             $reflectionClass->implementsInterface('Zend_Tool_Framework_Provider_Interface')
   152                 && !$reflectionClass->isAbstract()
   152                 && !$reflectionClass->isAbstract()
   153                 && !$providerRegistry->hasProvider($reflectionClass->getName(), false)
   153                 && !$providerRegistry->hasProvider($reflectionClass->getName(), false)
   154         );
   154         );
   155     }
   155     }
   156     
   156 
   157 }
   157 }