本文整理匯總了PHP中ServiceLocator::addService方法的典型用法代碼示例。如果您正苦於以下問題:PHP ServiceLocator::addService方法的具體用法?PHP ServiceLocator::addService怎麽用?PHP ServiceLocator::addService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ServiceLocator
的用法示例。
在下文中一共展示了ServiceLocator::addService方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getServiceLocator
/**
* Gets the service locator (experimental).
* @return IServiceLocator
*/
public final function getServiceLocator()
{
if ($this->serviceLocator === NULL) {
$this->serviceLocator = new ServiceLocator(Environment::getServiceLocator());
foreach ($this->defaultServices as $name => $service) {
if (!$this->serviceLocator->hasService($name)) {
$this->serviceLocator->addService($name, $service);
}
}
}
return $this->serviceLocator;
}
示例2: createServiceLocator
/**
* Get initial instance of service locator.
* @return IServiceLocator
*/
public function createServiceLocator()
{
$locator = new ServiceLocator();
foreach ($this->defaultServices as $name => $service) {
$locator->addService($service, $name);
}
return $locator;
}