Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Matthias Noback: Symfony2: Event subsystems

Matthias Noback: Symfony2: Event subsystems

In his latest post Mathias Noback takes a look at the Symfony2 event subsystems and the answer to a common problem he’s had with it in the past: circular references.

Recently I realized that some of the problems I encountered in the past could have been easily solved by what I’m about to explain in this post. [...] The problem is: having a complicated graph of service definitions and their dependencies, which causes a ServiceCircularReferenceException, saying ‘Circular reference detected for service “…”, path: “… -> … -> …”.’ Somewhere in the path of services that form the circle you then find the event_dispatcher service.

He shows the wrong way to solve the problem first by injecting a service container into the listener and using services directly from there. In his “entirely different and much better way” he shows a solution that removes dependencies on the main event dispatcher. He shows how to use the event subsystems to avoid this link and gives a more concrete example for domain-related events (with both code and config).

Link: http://php-and-symfony.matthiasnoback.nl/2014/08/symfony2-event-subsystems/
Source: http://www.phpdeveloper.org/news/21620

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Posted Sierpień 25th, 2014 in WEB and PHP Development.

Leave a response: