本文整理汇总了PHP中Pimple\Container::registerSubscriber方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::registerSubscriber方法的具体用法?PHP Container::registerSubscriber怎么用?PHP Container::registerSubscriber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimple\Container
的用法示例。
在下文中一共展示了Container::registerSubscriber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* @param Container $container
*/
public function register(Container $container)
{
if (!$container instanceof Application) {
throw new \InvalidArgumentException("invalid application");
}
/**
* pimple aware event dispatcher
*/
$container->register(new PimpleAwareEventDispatcherServiceProvider());
/**
* alias for auto injection
*/
$container[PimpleAwareEventDispatcher::class] = function () use($container) {
return $container["dispatcher"];
};
/**
* register default event subscriber
*/
$container->registerSubscriber(ExceptionHandler::class, function () use($container) {
return new ExceptionHandler($container["config"], $container["monolog"]);
});
$container->registerSubscriber(CliExceptionHandler::class, function () use($container) {
return new CliExceptionHandler($container["config"], $container["monolog"]);
});
}
示例2: subscribe
/**
* {@inheritdoc}
*/
public function subscribe(Container $container, EventDispatcherInterface $dispatcher)
{
if (!$container instanceof Singo) {
throw new \InvalidArgumentException("Container must be instance of " . Singo::class);
}
/**
* register login log subscriber
*/
$container->registerSubscriber(LogLogin::class, function () use($container) {
return new LogLogin($container["monolog"]);
});
}