/** * @ActivityListQueryDesigner $queryDesigner * * @return DatagridInterface */ public function createGrid(ActivityListQueryDesigner $source) { $this->datagridConfigurationBuilder->setGridName('related-activity'); $this->datagridConfigurationBuilder->setSource($source); $config = $this->datagridConfigurationBuilder->getConfiguration(); $stopPropagationListener = function (Event $e) { $e->stopPropagation(); }; $this->eventDispatcher->addListener(BuildBefore::NAME, $stopPropagationListener, 255); $grid = $this->gridBuilderLink->getService()->build($config, new ParameterBag()); $this->eventDispatcher->removeListener(BuildBefore::NAME, $stopPropagationListener); return $grid; }
public function detachEvents() { foreach ($this->attachedEvents as $eventInfo) { $this->eventDispatcher->removeListener($eventInfo['key'], $eventInfo['callback']); } $this->attachedEvents = []; }
/** * Removes an event listener for the given event name. * * @param string $eventName The event name. * @param callable $listener The callback to remove. * * @return static The current instance. * * @see EventDispatcherInterface::removeListener() */ public function removeEventListener($eventName, $listener) { if (!$this->dispatcher) { $this->dispatcher = new EventDispatcher(); } $this->dispatcher->removeListener($eventName, $listener); return $this; }
/** * Activate cross processes tunnel. * NB: Should be called only in child process! * Removes all current registered listeners. */ public function activate() { foreach ($this->dispatcher->getListeners() as $event => $listeners) { foreach ($listeners as $listener) { $this->dispatcher->removeListener($event, $listener); } } foreach ($this->events as $event) { $this->dispatcher->addListener($event, [$this, 'onEvent']); } foreach ($this->sockets as $socket) { fclose($socket); } fclose($this->childSocket); }
public function __invoke(FilterResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $request = $event->getRequest(); $response = $event->getResponse(); $session = $this->getSession(); /** @var ApiOauthToken $token */ $token = $session->get('token'); $this->getApiLogManipulator()->create($token->getAccount(), $request, $response); $this->getApiOAuthTokenManipulator()->setLastUsed($token, new \DateTime()); $session->set('token', null); if (null !== $this->getAuthenticator()->getUser()) { $this->getAuthenticator()->closeAccount(); } $dispatcher->removeListener($eventName, $this); }
/** * Unregisters the dispatcher. * * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance */ public function unregister(EventDispatcherInterface $dispatcher) { $dispatcher->removeListener(KernelEvents::EXCEPTION, array($this, 'onKernelException')); }
/** * Flush handlers. * * Clears all handlers. * * @return void */ public function flushHandlers() { foreach ($this->dispatcher->getListeners() as $eventName => $listener) { $this->dispatcher->removeListener($eventName, $listener); } }
/** * @inheritdoc */ public function removeListener($eventName, callable $listener) { $this->dispatcher->removeListener($eventName, $listener); }
/** * Removes an event listener from the specified events. * * @param string|array $eventName The event(s) to remove a listener from. * * @param callable $listener The listener to remove. * * @return void */ public function removeListener($eventName, $listener) { $this->realDispatcher->removeListener($eventName, $listener); }
/** * {@inheritdoc} */ public function removeListener($eventName, $listener) { return $this->dispatcher->removeListener($eventName, $listener); }
/** * Removes an event listener from the specified events. * * @param string $eventName The event to remove a listener from * @param callable $listenerToBeRemoved The listener to remove */ public function removeListener($eventName, $listenerToBeRemoved) { $this->symfonyDispatcher->removeListener($eventName, $listenerToBeRemoved); }
/** * Configures the error handler. * * @param Event|null $event The triggering event * @param string|null $eventName The triggering event name * @param EventDispatcherInterface|null $eventDispatcher The dispatcher used to trigger $event */ public function configure(Event $event = null, $eventName = null, EventDispatcherInterface $eventDispatcher = null) { if (null !== $eventDispatcher) { foreach (array_keys(static::getSubscribedEvents()) as $name) { $eventDispatcher->removeListener($name, array($this, 'configure')); } } $handler = set_error_handler('var_dump', 0); $handler = is_array($handler) ? $handler[0] : null; restore_error_handler(); if ($handler instanceof ErrorHandler) { if ($this->logger) { $handler->setDefaultLogger($this->logger, $this->levels); if (is_array($this->levels)) { $scream = 0; foreach ($this->levels as $type => $log) { $scream |= $type; } } else { $scream = null === $this->levels ? E_ALL | E_STRICT : $this->levels; } if ($this->scream) { $handler->screamAt($scream); } $this->logger = $this->levels = null; } if (null !== $this->throwAt) { $handler->throwAt($this->throwAt, true); } } if (!$this->exceptionHandler) { if ($event instanceof KernelEvent) { $this->exceptionHandler = array($event->getKernel(), 'terminateWithException'); } elseif ($event instanceof ConsoleEvent && ($app = $event->getCommand()->getApplication())) { $output = $event->getOutput(); if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $this->exceptionHandler = function ($e) use($app, $output) { $app->renderException($e, $output); }; } } if ($this->exceptionHandler) { $handler = set_exception_handler('var_dump'); $handler = is_array($handler) ? $handler[0] : null; restore_exception_handler(); if ($handler instanceof ErrorHandler) { $h = $handler->setExceptionHandler('var_dump') ?: $this->exceptionHandler; $handler->setExceptionHandler($h); $handler = is_array($h) ? $h[0] : null; } if ($handler instanceof ExceptionHandler) { $handler->setHandler($this->exceptionHandler); if (null !== $this->fileLinkFormat) { $handler->setFileLinkFormat($this->fileLinkFormat); } } $this->exceptionHandler = null; } }
/** * Invoke the handler. * * @param Event $event The event. * * @param string $eventName The event name. * * @param EventDispatcherInterface $dispatcher The dispatcher. * * @return void */ public function __invoke(Event $event, $eventName, $dispatcher) { $dispatcher->removeListener($eventName, $this); call_user_func($this->handler, $event, $eventName, $dispatcher); }