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']);
 }
 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());
 }
 /**
  * {@inheritDoc}
  */
 public function addSubscriber(EventSubscriberInterface $subscriber)
 {
     if (!$this->primaryEventDispatcher) {
         throw new \RuntimeException('Undefined primary event dispatcher');
     }
     $this->primaryEventDispatcher->addSubscriber($subscriber);
 }
Example #4
0
 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']);
 }
 /**
  * {@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;
 }
Example #6
0
 /**
  * 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']);
 }
Example #7
0
 /**
  * @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);
 }
Example #8
0
 /**
  * @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);
 }
Example #9
0
 /**
  * @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;
 }
Example #10
0
 /**
  * {@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);
 }
 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;
 }
Example #12
0
 /**
  * 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;
 }
 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);
 }
Example #14
0
 /**
  * @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));
 }
Example #15
0
 /**
  * @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;
 }
Example #16
0
 /**
  * Build the rest adapter
  *
  * @return RestAdapter
  * @throws RetrofitException
  */
 public function build()
 {
     if (null === $this->baseUrl) {
         throw new RetrofitException('Could not build RestAdapter with null $baseUrl');
     }
     if (null === $this->serializer && null === $this->serializerAdapter) {
         $this->serializerAdapter = new JmsSerializerAdapter(SerializerBuilder::create()->build());
         $this->deserializerAdapter = $this->serializerAdapter;
     }
     if (null === $this->eventDispatcher) {
         $this->eventDispatcher = new EventDispatcher();
     }
     foreach ($this->subscribers as $subscriber) {
         $this->eventDispatcher->addSubscriber($subscriber);
     }
     if (null === $this->logger) {
         $this->logger = new NullLogger();
     }
     if ($this->useLogSubscriber) {
         $this->eventDispatcher->addSubscriber(new LogSubscriber($this->logger));
     }
     $client = $this->clientProvider->getClient();
     if ($client instanceof EventDispatcherAware) {
         $client->setEventDispatcher($this->eventDispatcher);
     }
     $adapter = new RestAdapter($this->baseUrl, $client, $this->eventDispatcher, $this->serializerAdapter, $this->deserializerAdapter);
     return $adapter;
 }
 public function subscribe(Container $container, EventDispatcherInterface $dispatcher)
 {
     $dispatcher->addSubscriber($container['session.listener']);
     if ($container['session.test']) {
         $container['event_dispatcher']->addSubscriber($container['session.listener.test']);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function subscribe(EventDispatcherInterface $dispatcher)
 {
     $app = $this->getContainer();
     if (count($app['translate.config']->getLocales()) !== 0) {
         $dispatcher->addSubscriber(new EventListener\StorageListener($app['config'], $app['translate.config'], $app['query'], $app['request_stack']));
     }
 }
Example #19
0
 /**
  * Registers the processor subscriber if processors are available.
  *
  * @return BuildCommand For method chaining.
  */
 private function registerProcessors()
 {
     if (0 < count($this->resolver->getProcessors())) {
         $this->dispatcher->addSubscriber(new ProcessorSubscriber(new DelegatingProcessor($this->resolver)));
     }
     return $this;
 }
 public function instance(Connection $db, EventDispatcherInterface $event, LogInterface $logBridge, $tableName)
 {
     # bind events to logbridge
     $event->addSubscriber(new LogSubscriber($logBridge));
     # create an API instance
     return new Tag($event, new TagMapper($event, new TagGateway($tableName, $db, $event, $this->getDatabseMetaData($tableName), null, new TagBuilder())));
 }
Example #21
0
 /**
  * Adds an event subscriber to the dispatcher.
  *
  * @param EventSubscriberInterface $subscriber The subscriber to add.
  *
  * @return static The current instance.
  *
  * @see EventDispatcherInterface::addSubscriber()
  */
 public function addEventSubscriber(EventSubscriberInterface $subscriber)
 {
     if (!$this->dispatcher) {
         $this->dispatcher = new EventDispatcher();
     }
     $this->dispatcher->addSubscriber($subscriber);
     return $this;
 }
 public function subscribe(Devaloka $devaloka, ContainerInterface $container, EventDispatcherInterface $dispatcher)
 {
     if (!$this->subscribe) {
         return;
     }
     $listener = $container->get('devaloka.plugin.query_exporter.query_exporter_listener');
     $dispatcher->addSubscriber($listener);
 }
Example #23
0
 private function enableHtmlReport(EventDispatcherInterface $dispatcher, $htmlReportFilename)
 {
     if ($htmlReportFilename !== null) {
         $html = $this->container['subscriber.html'];
         $html->setReportFilename($htmlReportFilename);
         $dispatcher->addSubscriber($html);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function addEventSubscriber(EventSubscriberInterface $subscriber)
 {
     if ($this->locked) {
         throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
     }
     $this->dispatcher->addSubscriber($subscriber);
     return $this;
 }
Example #25
0
 /**
  * {@inheritdoc}
  */
 public function addEventSubscriber(EventSubscriberInterface $subscriber)
 {
     if ($this->locked) {
         throw new FormException('The config builder cannot be modified anymore.');
     }
     $this->dispatcher->addSubscriber($subscriber);
     return $this;
 }
Example #26
0
 /**
  * @return ClientInterface
  */
 public function build()
 {
     $soapClientFactory = new SoapClientFactory($this->classMaps, $this->converters);
     $soapClient = $soapClientFactory->factory($this->wsdl, $this->soapOptions);
     if ($this->logger) {
         $this->dispatcher->addSubscriber(new LogPlugin($this->logger));
     }
     return $this->clientFactory->factory($soapClient, $this->dispatcher);
 }
 /**
  * (non-PHPdoc).
  *
  * @see \Mathielen\ImportEngine\Import\Workflow\WorkflowFactoryInterface::buildDryrunWorkflow()
  */
 public function buildDryrunWorkflow(Import $import, ImportRun $importRun = null)
 {
     //build basics
     $workflow = $this->buildBaseWorkflow($import);
     //collect statistics by default
     $statisticsCollector = new ImportRunEventSubscriber($import, true);
     $this->eventDispatcher->addSubscriber($statisticsCollector);
     return $workflow;
 }
 /**
  * {@inheritdoc}
  */
 public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
 {
     $dispatcher->addListener(KernelEvents::REQUEST, function (GetResponseEvent $event) use($app) {
         if ($event->isMasterRequest()) {
             $app['routing.i18n_loader']->load($app['routes']);
         }
     }, 48);
     // Execute before the Router have access to the _locale
     $dispatcher->addSubscriber($app['routing.i18n.event_listener.cookie_setting']);
 }
Example #29
0
 /**
  * run Application
  */
 public function run()
 {
     $this->container->get(Firewall::class);
     $response = $this->container->get(TwigResponse::class);
     $response->setTemplate('error/404');
     try {
         $this->eventDispatcher->addSubscriber($this->routerListener);
         $response = $this->httpKernel->handle($this->request);
     } catch (ResourceNotFoundException $e) {
         $response->setContent(['message' => $e->getMessage(), 'exceptionClass' => get_class($e), 'trace' => $e->getTrace()]);
         //            throw $e;
     } catch (\Exception $e) {
         $response->setContent(['message' => $e->getMessage(), 'exceptionClass' => get_class($e), 'trace' => $e->getTrace()]);
         //            throw $e;
     } finally {
         $response->send();
         $this->httpKernel->terminate($this->request, $response);
     }
 }
Example #30
0
 /**
  * Enable formatter by name provided.
  *
  * @param string $formatter
  */
 public function enableFormatter($formatter)
 {
     if (!$this->isFormatterRegistered($formatter) && class_exists($formatter)) {
         $formatterInstance = new $formatter();
         $formatter = $formatterInstance->getName();
         if (!$this->isFormatterRegistered($formatter)) {
             $this->registerFormatter($formatterInstance);
         }
     }
     $this->eventDispatcher->addSubscriber($this->getFormatter($formatter));
 }