本文整理汇总了PHP中Phalcon\DiInterface::getServices方法的典型用法代码示例。如果您正苦于以下问题:PHP DiInterface::getServices方法的具体用法?PHP DiInterface::getServices怎么用?PHP DiInterface::getServices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\DiInterface
的用法示例。
在下文中一共展示了DiInterface::getServices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param DiInterface $di
* @param array $serviceNames
*/
public function __construct($di, $serviceNames = ['db' => ['db'], 'dispatch' => ['dispatcher'], 'view' => ['view']])
{
$this->di = $di;
$this->startTime = microtime(true);
$this->profiler = new Profiler();
$eventsManager = $di->get('eventsManager');
foreach ($di->getServices() as $service) {
$name = $service->getName();
foreach ($serviceNames as $eventName => $services) {
if (in_array($name, $services)) {
$service->setShared(true);
$di->get($name)->setEventsManager($eventsManager);
break;
}
}
}
foreach (array_keys($serviceNames) as $eventName) {
$eventsManager->attach($eventName, $this);
}
$this->serviceNames = $serviceNames;
}
示例2: __construct
/**
* DebugWidget constructor.
* @param DiInterface $di
* @param array $serviceNames
* @param array $panels
*/
public function __construct($di, $serviceNames = array('db' => array('db'), 'dispatch' => array('dispatcher'), 'view' => array('view')), $panels = array('server', 'request', 'views', 'db'))
{
$this->_di = $di;
$this->startTime = microtime(true);
$this->_profiler = new Profiler();
$eventsManager = $di->get('eventsManager');
foreach ($di->getServices() as $service) {
/** @var Di\Service $service */
$name = $service->getName();
foreach ($serviceNames as $eventName => $services) {
if (in_array($name, $services)) {
$service->setShared(true);
$di->get($name)->setEventsManager($eventsManager);
break;
}
}
}
foreach (array_keys($serviceNames) as $eventName) {
$eventsManager->attach($eventName, $this);
}
$this->_serviceNames = $serviceNames;
$this->_panels = $panels;
}