S
S
symnoob2018-05-17 13:56:21
symfony
symnoob, 2018-05-17 13:56:21

Symfony 4 - Block injection, how best to implement?

Good afternoon forum!
is there any functionality for embedding blocks in content?
I have several controllers that serve as forms.
I would like to create something like a helper, to which you can pass parameters and implement this part in each controller.
otherwise, you have to create an additional method in each controller, which is very inconvenient.
How can this be done more elegantly?
I will be glad to every suggestion and links to examples or documentation for symphony 4.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2018-05-17
@fornit1917

Make a separate class with a method that will do what you need, and inject it as a service where you need it and call it.
https://symfony.com/doc/current/best_practices/bus...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question