T
T
TigranAM2012-06-20 10:32:21
symfony
TigranAM, 2012-06-20 10:32:21

"Global Method" in Symfony2

Advise how to create a global controller (method) for code reuse, for example, to display layout.html.twig variables.
But in order not to refer to this method via Forward in each controller

Answer the question

In order to leave comments, you need to log in

5 answer(s)
C
cystbear, 2012-06-21
@TigranAM

TigranAM please give a specific example of what you need to do. I will try to help.

A
andrew_tch, 2012-06-20
@andrew_tch

Boy, go shit coding something normal, please.
And yes, this is from one of the sf2 developers who is one of a hundred committers.
Subject - make one abstract class MyController extends Controller, it has the doSomeShit method, and inherit all your controllers from it. Then it will be possible to do return $this->doSomeShit() in them

N
nuclear, 2012-06-20
@nuclear

What exactly is needed?
Any template can render any action{% render "AppDefaultBundle:Default:action" %}

S
shagguboy, 2012-06-20
@shagguboy

make a new namespace. it has a class. make this class a service. service can be pulled from anywhere.

M
MuXaJIbI4, 2012-06-20
@MuXaJIbI4

You can make one common controller and put all the global methods there. And then already inherit your controllers from this common controller. Thus, common methods will be available everywhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question