Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to access 'templating' service not in controller
    primarykey
    data
    text
    <p>Ok, so the problem is:</p> <p>I've got some 'order' entity, and it has 'status' property. On changing status, i wanted some other objects to be informed of this event, so i've decided to use Observer pattern. One of the observers notifies clients via email. Now i want to render Email text's from some of the twig templates. As i get from the Book, rendering templates in controllers are done with 'templating' service. </p> <p>So the question as it follows: How can i access 'templating' service in my Observer class?</p> <p>Specification: I was advised, to implement my Observer as a service, but i'm not sure 'bout that. I've tried to solve this problem, and here is my options:</p> <ol> <li><p>Use Registry. Solution that is straight and hard as rail. I guess it misses the whole point of DI and Service Container. Huge plus of this solution, is that i can access all common services from any point of my application.</p></li> <li><p>To pass needed services from the context via constructor, or via setters. This is more like in Sf2 spirit. There comes another list of problems, which are not related to this question field.</p></li> <li><p>Use observers as a service. I'm not really sure 'bout this option 'cos, in the book it is written, that service is a <em>common</em> functionality, and i don't think that observing entity with number of discrete properties is a common task.</p></li> </ol> <p>I'm looking for a Sf2 spirit solution, which will be spread over whole project, so all answers with an explanation are appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload