Rectangle 27 0

php How to solve some problems in symfony 2?


$request = $this->container->get('request');
$stack = $this->container->get('request_stack');

1) By accessing the '_controller' parameter of the request, you are delving into the internals of Symfony2. They rarely document anything related to this outside of routing. You should use controller actions more definitively, don't try to automate too much on this level.

2) Symfony2 can't account for highly dynamic controllers. You know it is possible to call ->forward more than once, and within the same controller action. This creates a nesting nightmare that the Symfony developers weren't prepared to deal with.

3) Also deprecated. Symfony2 best practices now discourages the use of @Template() with empty parameters because of the potentially volatile development of actions/templates. You are supposed to explicitly define which template to use, if you use one at all. This comes in handy when dealing with data-only responses. You wouldn't want your responses to use a template automatically as this would result in unexpected behaviour in your design.

@Gizzmo While 4) may be a little inconsistent with the general design of symfony, it is not bad practice. The use of public properties is a paradigm of older OOP languages and has been incorporated into PHP. If ever true getters and setters are implemented to PHP, you would no longer consider it bad design.

@Gizzmo stackoverflow.com/a/17881367/1692906 These are ideal. Opposed to the current get* and set* methods we are used to creating.

Thx Flosculus, 1) sad that is is like that, i have to support old URLs and need such funtion, 2) than this do not work eihter => i have to to do it on myown 3) is ok 4) is simply bad programming than...

wut;-) it is not bad practice? sure it is bad ihmo. But What you mean by "true getters and setters..."

Note
Rectangle 27 0

php How to solve some problems in symfony 2?


$request = $this->container->get('request');
$stack = $this->container->get('request_stack');

1) By accessing the '_controller' parameter of the request, you are delving into the internals of Symfony2. They rarely document anything related to this outside of routing. You should use controller actions more definitively, don't try to automate too much on this level.

2) Symfony2 can't account for highly dynamic controllers. You know it is possible to call ->forward more than once, and within the same controller action. This creates a nesting nightmare that the Symfony developers weren't prepared to deal with.

3) Also deprecated. Symfony2 best practices now discourages the use of @Template() with empty parameters because of the potentially volatile development of actions/templates. You are supposed to explicitly define which template to use, if you use one at all. This comes in handy when dealing with data-only responses. You wouldn't want your responses to use a template automatically as this would result in unexpected behaviour in your design.

@Gizzmo While 4) may be a little inconsistent with the general design of symfony, it is not bad practice. The use of public properties is a paradigm of older OOP languages and has been incorporated into PHP. If ever true getters and setters are implemented to PHP, you would no longer consider it bad design.

@Gizzmo stackoverflow.com/a/17881367/1692906 These are ideal. Opposed to the current get* and set* methods we are used to creating.

Thx Flosculus, 1) sad that is is like that, i have to support old URLs and need such funtion, 2) than this do not work eihter => i have to to do it on myown 3) is ok 4) is simply bad programming than...

wut;-) it is not bad practice? sure it is bad ihmo. But What you mean by "true getters and setters..."

Note