I am wondering where should I place constants, for example. to display status in symfony. I am used to installing them in the controller, but this is not so, and I prefer the essence, but not quite.
What right?
This is not "what do you think?" - the question is, I really want to know best practices and evaluate explanations or related sources. Both work, for now.
the controller or
namespace my\bundle\Controller;
class MyController {
const STATUS_NEW = 1;
const STATUs_PENDING = 2;
}
Object ?
namespace my\bundle\Entity;
class MyEntity {
const STATUS_NEW = 1;
const STATUs_PENDING = 2;
}
Example in a branch:
{% set statusNew = constant('my\\bundle\\Controller\\MyController::STATUS_NEW')%} {
{% if data.status == statusNew %}
Hi, I'm new.
{% endif %}
Thanks in advance!
M.
source
share