Questions tagged [symfony-eventdispatcher]

The EventDispatcher is a Symfony Component provides tools that allow your application components to communicate with each other by dispatching events and listening to them.

30 questions
7
votes
2 answers

Catching terminal terminations/exits with Symfony Console (CTRL+C)

I have built a command which triggers file downloads from over the internet, however since these files need to be processed by another component, we need to make sure that every file that has been downloaded and has not been modified in the last 10…
GiamPy
  • 3,543
  • 3
  • 30
  • 51
6
votes
1 answer

Symfony 5 security.interactive_login event not called

I want to use the security.interactive_login event to update my User's last login field. The event is successfully registered: php bin/console debug:event-dispatcher security.interactive_login Registered Listeners for "security.interactive_login"…
Erdal G.
  • 2,694
  • 2
  • 27
  • 37
2
votes
2 answers

symfony 5 - event not being dispatched

I use an event subscriber to handle some actions when my order form is submitted. Problem my event is not being dispached but symfony is able to find him because he tells me that my OrderEvent::ORDER_CREATE is orphan. I excpected that execution was…
akio
  • 851
  • 9
  • 29
2
votes
1 answer

Symfony (5.1) Doctrine Event Listener is fired but not Entity Listener

Using Symfony official documentation, I was cleaning up some code and wanted to replace a Doctrine event listener in Symfony (working): namespace App\EventListener; use App\Entity\Comment; use Doctrine\ORM\Event\LifecycleEventArgs; use…
Erdal G.
  • 2,694
  • 2
  • 27
  • 37
2
votes
1 answer

How I can fire publish method once the event is fired?

I have the following event class definition: use Symfony\Contracts\EventDispatcher\Event; class CaseEvent extends Event { public const NAME = 'case.event'; // ... } And I have created a subscriber as follow: use App\Event\CaseEvent; use…
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
1
vote
1 answer

Capturing exceptions from event listeners in Symfony so that they don't stop other listeners

I have a problem in a Symfony 4.4 application where there are a dozen listeners listening to a single event that extends Symfony\Contracts\EventDispatcher\Event. The problem is that if one of the listeners throws an exception, then none of the…
Chris
  • 4,277
  • 7
  • 40
  • 55
1
vote
2 answers

Why isn't InteractiveLoginEvent not fired with Symfony's 5.1 new security system?

With the new Symfony 5.1 security system, I'm not able to fire the InteractiveLoginEvent. I followed the configuration in the official documentation (here and here) and the system was working perfectly in the former security system. Below is my…
1
vote
1 answer

Symfony 4.4 Event Dispatcher

I'm getting the following error: Service "event_dispatcher" not found: even though it exists in the app's container, the container inside "App\Controller\RatingApiController" is a smaller service locator that only knows about the "form.factory",…
Anonymous
  • 47
  • 8
1
vote
0 answers

Symfony4 and Event Dispatcher issue, the script continues 25 seconds after the event

i have a issue with Event Dispatcher on Symfony4. The script contnues 25 seconds after the event finished . Here the code: controller (necessary part): $this->logger->notice("Log Start"); $response = new JsonResponse($responseArray,…
AndreaS
  • 11
  • 1
1
vote
1 answer

Why do I get "An error occurred while loading the web debug toolbar." when using this Event Subscriber?

I'm creating configured maintenance page. I created an event subscriber: public function onKernelRequest(RequestEvent $event) { $maintenance = $this->container->hasParameter('maintenance') ?…
nicram
  • 353
  • 3
  • 7
  • 24
1
vote
1 answer

How to make a Service works on kernel.terminate like SwiftMailer works?

I was wondering how to write a service that is executed only on kernel.terminate. For instance when I call: $message = (new \Swift_Message('A new book has been added')) ->setFrom('system@example.com') …
1
vote
0 answers

symfony 3: how to get the updated data in addEventSubscriber of form type?

Symfony version: 3.4 i have a root form is layout form that is including a collection type is named blocks. The content form is belonged to blocks form. I want to use ajax to making user change the value of selector 1 and then the form type 2 is…
1
vote
0 answers

How to use services defined in PHP-DI in the Symfony's services.yaml?

I'm writing an application, that has a structure of a Symfony application and some Symfony functionality, but should be decoupled from the framework as possible. So instead of the framework's DI, I'm using PHP-DI. Now I need Symfony's…
automatix
  • 14,018
  • 26
  • 105
  • 230
1
vote
1 answer

How to register event listeners in Symfony 4?

I'm writing a Symfony application. Means: The application has a structure of a Symfony application and uses Symfony's MVC (symfony/http-kernel, symfony/routing etc.), but it should be as framework-independent as possible. So instead of the…
automatix
  • 14,018
  • 26
  • 105
  • 230
1
vote
2 answers

What is the $subject in the Symfony GenericEvent?

The GenericEvent of the symfony/event-dispatcher package provides two properties -- subject and arguments. If I understand the docu correctly, the arguments can be used for passing context data into the Event object. But I'm not getting, how to use…
automatix
  • 14,018
  • 26
  • 105
  • 230
1
2