Beispiel #1
0
    /**
     * _processSpecialties() - Break out the specialty names for this provider
     *
     */
    protected function _processSpecialties()
    {
        $specialties = array();

        if ($this->_providerReflection->hasMethod('getSpecialties')) {
            $specialties = $this->_provider->getSpecialties();
            if (!is_array($specialties)) {
                require_once 'Zend/Tool/Framework/Provider/Exception.php';
                throw new Zend_Tool_Framework_Provider_Exception(
                    'Provider ' . get_class($this->_provider) . ' must return an array for method getSpecialties().'
                    );
            }
        } else {
            $defaultProperties = $this->_providerReflection->getDefaultProperties();
            $specialties = (isset($defaultProperties['_specialties'])) ? $defaultProperties['_specialties'] : array();
            if (!is_array($specialties)) {
                require_once 'Zend/Tool/Framework/Provider/Exception.php';
                throw new Zend_Tool_Framework_Provider_Exception(
                    'Provider ' . get_class($this->_provider) . '\'s property $_specialties must be an array.'
                    );
            }
        }

        $this->_specialties = array_merge(array('_Global'), $specialties);

    }
Beispiel #2
0
 /**
  * Add a provider to the repository for processing
  *
  * @param Zend_Tool_Framework_Provider_Interface $provider
  * @return Zend_Tool_Framework_Provider_Repository
  */
 public function addProvider(Zend_Tool_Framework_Provider_Interface $provider, $overwriteExistingProvider = false)
 {
     if ($provider instanceof Zend_Tool_Framework_Registry_EnabledInterface) {
         $provider->setRegistry($this->_registry);
     }
     if (method_exists($provider, 'getName')) {
         $providerName = $provider->getName();
     } else {
         $providerName = $this->_parseName($provider);
     }
     // if a provider by the given name already exist, and its not set as overwritable, throw exception
     if (!$overwriteExistingProvider && (array_key_exists($providerName, $this->_unprocessedProviders) || array_key_exists($providerName, $this->_providers))) {
         throw new Zend_Tool_Framework_Provider_Exception('A provider by the name ' . $providerName . ' is already registered and $overrideExistingProvider is set to false.');
     }
     $this->_unprocessedProviders[$providerName] = $provider;
     // if process has already been called, process immediately.
     if ($this->_processOnAdd) {
         $this->process();
     }
     return $this;
 }