Refresh again. It still works! But how? We didn't tell Symfony what arguments to pass to our constructor? What madness is this!? With autowire: true, Symfony reads the type-hints for each constructor argument:
And tries to automatically find the correct service to pass to you. In this case, it saw the MarkdownTransformer type-hint and knew to use the app.markdown_transformer service: since that is an instance of this class. You can also type-hint interfaces.
The HTML is still being escaped - I don't want to finish before we fix that! We could add the |raw filter... but let's do something cooler. Add a third argument to Twig_SimpleFilter: an options array. Add is_safe set to an array containing html:
Oh my gosh guys! I think you just leveled up: Symfony offense increased by five points. Besides the fact that a lot more things will start making sense in Symfony, you also know everything you need to start organizing your code into service classes - that whole service-oriented architecture thing I was talking about earlier. This will lead you to wonderful applications.
There's really nothing that we can't do now in Symfony. In the next courses, we'll use all this to master new tools like forms and security. Seeya next time!