本文整理汇总了PHP中Phalcon\Di::setInternalEventsManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Di::setInternalEventsManager方法的具体用法?PHP Di::setInternalEventsManager怎么用?PHP Di::setInternalEventsManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Di
的用法示例。
在下文中一共展示了Di::setInternalEventsManager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Fix over clever di service resolver in phalcon 2.1.x:
* let definition = \Closure::bind(definition, dependencyInjector)
* which leads to php warning "Cannot bind an instance to a static closure"
*
* @param Di $di
* @codeCoverageIgnore
*/
public static function register(Di $di)
{
if ($_SERVER['PHWOOLCON_PHALCON_VERSION'] > '2010000') {
$di->setInternalEventsManager($di->getShared('eventsManager'));
Events::attach('di:beforeServiceResolve', function (Event $event) {
/* @var Di $di */
$di = $event->getSource();
$data = $event->getData();
$name = $data['name'];
$parameters = $data['parameters'];
if (!isset($di->_services[$name])) {
return false;
}
/* @var Di\Service $service */
$service = $di->_services[$name];
if (!$service->isShared()) {
return false;
}
if (!($definition = $service->getDefinition()) instanceof Closure) {
return false;
}
return $parameters ? call_user_func_array($definition, $parameters) : call_user_func($definition);
});
}
}
示例2: setInternalEventsManager
public function setInternalEventsManager(ManagerInterface $eventsManager)
{
parent::setInternalEventsManager($eventsManager);
}