本文整理汇总了PHP中Symfony\Component\EventDispatcher\EventDispatcherInterface::addSubscriber方法的典型用法代码示例。如果您正苦于以下问题:PHP EventDispatcherInterface::addSubscriber方法的具体用法?PHP EventDispatcherInterface::addSubscriber怎么用?PHP EventDispatcherInterface::addSubscriber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\EventDispatcher\EventDispatcherInterface
的用法示例。
在下文中一共展示了EventDispatcherInterface::addSubscriber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: subscribe
public function subscribe(Container $c, EventDispatcherInterface $dispatcher)
{
$dispatcher->addSubscriber($c['extra.controller_listener']);
$dispatcher->addSubscriber($c['extra.paramconverter_listener']);
$dispatcher->addSubscriber($c['extra.httpcache_listener']);
$dispatcher->addSubscriber($c['extra.security_listener']);
}
示例2: subscribe
public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{
$dispatcher->addSubscriber(new ResponseListener($app['charset']));
$dispatcher->addSubscriber(new MiddlewareListener($app['app']));
$dispatcher->addSubscriber(new ConverterListener($app['routes'], $app['callback_resolver']));
$dispatcher->addSubscriber(new StringToResponseListener());
}
示例3: addSubscriber
/**
* {@inheritDoc}
*/
public function addSubscriber(EventSubscriberInterface $subscriber)
{
if (!$this->primaryEventDispatcher) {
throw new \RuntimeException('Undefined primary event dispatcher');
}
$this->primaryEventDispatcher->addSubscriber($subscriber);
}
示例4: bindRequestListeners
private function bindRequestListeners(Application $app, EventDispatcherInterface $dispatcher)
{
$dispatcher->addSubscriber($app['alchemy_rest.decode_request_listener']);
$dispatcher->addSubscriber($app['alchemy_rest.paginate_request_listener']);
$dispatcher->addSubscriber($app['alchemy_rest.sort_request_listener']);
$dispatcher->addSubscriber($app['alchemy_rest.date_request_listener']);
}
示例5: build
/**
* {@inheritdoc}
*/
public function build(ImporterTypeInterface $type, Import $import, HandlerInterface $handler, ImportLogger $logger, array $options)
{
$resolver = $this->getOptionsResolver($type);
$type->build($this, $import, $handler, $resolver->resolve($options));
$importer = new Importer($import, $handler, $logger, $this->eventDispatcher);
$this->eventDispatcher->addSubscriber($importer);
return $importer;
}
示例6: subscribe
/**
* Define events to listen to here.
*
* @param EventDispatcherInterface $dispatcher
*/
protected function subscribe(EventDispatcherInterface $dispatcher)
{
$app = $this->getContainer();
$dispatcher->addSubscriber($this);
$dispatcher->addSubscriber($app['members.admin']);
$dispatcher->addSubscriber($app['members.session']);
$dispatcher->addSubscriber($app['members.listener.profile']);
}
示例7: __construct
/**
* @param Import $import
* @param HandlerInterface $handler
* @param EventDispatcherInterface $dispatcher
* @param int $batchSize
*/
public function __construct(Import $import, HandlerInterface $handler, EventDispatcherInterface $dispatcher, $batchSize = 20)
{
$this->import = $import;
$this->handler = $handler;
$this->eventDispatcher = $dispatcher;
$this->result = new ImportResult();
$this->setBatchSize($batchSize);
$this->eventDispatcher->addSubscriber($this);
}
示例8: attachTo
/**
* @param FileLibrary $filelib
*/
public function attachTo(FileLibrary $filelib)
{
$this->fileRepository = $filelib->getFileRepository();
$this->profiles = $filelib->getProfileManager();
$this->eventDispatcher = $filelib->getEventDispatcher();
$this->eventDispatcher->addSubscriber($this);
$this->adapter->attachTo($filelib);
$this->linker->attachTo($filelib);
}
示例9: addAnnotationHandler
/**
* @param AnnotationHandlerInterface $handler
* @return $this
* @throws \InvalidArgumentException
*/
public function addAnnotationHandler(AnnotationHandlerInterface $handler)
{
if (isset($this->annotationHandlers[$handler->getName()])) {
throw new \InvalidArgumentException($handler->getName() . ' is already registered');
}
$this->annotationHandlers[$handler->getName()] = $handler;
$this->dispatcher->addSubscriber($handler);
return $this;
}
示例10: __invoke
/**
* {@inheritdoc}
*/
public function __invoke(Request $request)
{
$context = new RequestContext();
$context->fromRequest($request);
$this->eventDispatcher->addSubscriber(new RouterListener(new UrlMatcher($this->routeCollection, $context)));
$kernel = new HttpKernel($this->eventDispatcher, new ControllerResolverActionResolverAdapter($this->actionResolver));
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
}
示例11: create
public function create($formatter, Platform $platform, $options = array())
{
$formatter = strtolower($formatter);
if (isset(self::$formatters[$formatter]) === false) {
throw new EngineException('Formatter does not exist at::' . $formatter);
}
$class = new self::$formatters[$formatter]($this->event, $this->writer->getWriter($platform->getName(), $formatter), $platform, $this->visitor, $options);
# register this formatter as a subscriber
$this->event->addSubscriber($class);
return $class;
}
示例12: addProfile
/**
* Adds a profile
*
* @param FileProfile $profile
* @return ProfileManager
* @throws InvalidArgumentException
*/
public function addProfile(FileProfile $profile)
{
$identifier = $profile->getIdentifier();
if (isset($this->profiles[$identifier])) {
throw new InvalidArgumentException("Profile '{$identifier}' already exists");
}
$this->profiles[$identifier] = $profile;
$this->eventDispatcher->addSubscriber($profile);
$event = new FileProfileEvent($profile);
$this->eventDispatcher->dispatch(Events::PROFILE_AFTER_ADD, $event);
return $this;
}
示例13: setUp
public function setUp()
{
parent::setUp();
$this->siteAccess = new SiteAccess();
$this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
$this->listener = new ConsoleCommandListener('default', $this->siteAccessList, $this->dispatcher);
$this->listener->setSiteAccess($this->siteAccess);
$this->dispatcher->addSubscriber($this->listener);
$this->command = new Command('test:siteaccess');
$this->inputDefinition = new InputDefinition(array(new InputOption('siteaccess', null, InputOption::VALUE_OPTIONAL)));
$this->testOutput = new TestOutput(Output::VERBOSITY_QUIET, true);
}
示例14: boot
/**
* @param EventDispatcherInterface $dispatcher
*/
public function boot(EventDispatcherInterface $dispatcher)
{
$context = new PhpGdContext();
$rh = new ResourceHelper();
$extractor = new GifExtractor();
$builder = new GifBuilder();
$builderPlus = new GifBuilderPlus();
$optimizer = new GifOptimizer($rh);
$factory = new ImageFactory($rh, $extractor, $builder, $builderPlus, $optimizer);
$dispatcher->addSubscriber(new GifExtractorListener($extractor));
$dispatcher->addSubscriber(new MemoryRequirementListener($context));
$dispatcher->addSubscriber(new ImageFactoryListener($factory));
}
示例15: addPlugin
/**
* @param Plugin $plugin
* @param array $profiles Profiles to add to, empty array to add to all profiles
* @param string $name
* @return PluginManager
*/
public function addPlugin(Plugin $plugin, $profiles = array(), $name = null)
{
if (!$name) {
$name = $this->generatePluginName($plugin);
}
if (isset($this->plugins[$name])) {
throw new InvalidArgumentException(sprintf("Plugin with the name '%s' already exists", $name));
}
$this->plugins[$name] = $plugin;
$this->setResolverFunction($plugin, $profiles);
$this->eventDispatcher->addSubscriber($plugin);
$event = new PluginEvent($plugin, $this->filelib);
$this->eventDispatcher->dispatch(Events::PLUGIN_AFTER_ADD, $event);
return $this;
}