本文整理匯總了PHP中Zend\ServiceManager\ServiceLocatorInterface::addAbstractFactory方法的典型用法代碼示例。如果您正苦於以下問題:PHP ServiceLocatorInterface::addAbstractFactory方法的具體用法?PHP ServiceLocatorInterface::addAbstractFactory怎麽用?PHP ServiceLocatorInterface::addAbstractFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\ServiceManager\ServiceLocatorInterface
的用法示例。
在下文中一共展示了ServiceLocatorInterface::addAbstractFactory方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createService
/**
* Class responsible for instantiating a DiAbstractServiceFactory
*
* @param ServiceLocatorInterface $serviceLocator
* @return DiAbstractServiceFactory
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$factory = new DiAbstractServiceFactory($serviceLocator->get('Di'), DiAbstractServiceFactory::USE_SL_BEFORE_DI);
if ($serviceLocator instanceof ServiceManager) {
/* @var $serviceLocator ServiceManager */
$serviceLocator->addAbstractFactory($factory);
}
return $factory;
}
示例2: createService
/**
* Create and return abstract factory seeded by dependency injector
*
* Creates and returns an abstract factory seeded by the dependency
* injector. If the "di" key of the configuration service is set, that
* sub-array is passed to a DiConfiguration object and used to configure
* the DI instance. The DI instance is then used to seed the
* DiAbstractServiceFactory, which is then registered with the service
* manager.
*
* @param ServiceLocatorInterface $serviceLocator
* @return Di
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$di = new Di();
$config = $serviceLocator->get('Configuration');
if (isset($config['di'])) {
$di->configure(new DiConfiguration($config['di']));
}
if ($serviceLocator instanceof ServiceManager) {
// register as abstract factory as well:
$serviceLocator->addAbstractFactory(new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI));
}
return $di;
}
示例3: registerAbstractFactory
/**
* @param ServiceLocatorInterface $sl
* @param Di $di
* @return void
*/
protected function registerAbstractFactory(ServiceLocatorInterface $sl, Di $di)
{
if ($sl instanceof ServiceManager) {
/* @var $sl ServiceManager */
$sl->addAbstractFactory(new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI));
}
}