本文整理汇总了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));
}
}