/** * _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)) { throw new Exception\RuntimeException('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)) { throw new Exception\RuntimeException('Provider ' . get_class($this->_provider) . '\'s property $_specialties must be an array.'); } } $this->_specialties = array_merge(array('_Global'), $specialties); }
/** * Add a provider to the repository for processing * * @param Provider $provider * @return Provider\Repository */ public function addProvider(Provider $provider, $overwriteExistingProvider = false) { if ($provider instanceof RegistryEnabled) { $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 Exception\InvalidArgumentException(sprintf('A provider by the name "%s" is already registered and $overrideExistingProvider is set to false', $providerName)); } $this->_unprocessedProviders[$providerName] = $provider; // if process has already been called, process immediately. if ($this->_processOnAdd) { $this->process(); } return $this; }