I have a few class constants in my entity class, e.g.:
class Entity {
const TYPE_PERSON = 0;
const TYPE_COMPANY = 1;
}
In normal PH
In book best practices of Symfony there is a section with this issue:
Constants can be used for example in your Twig templates thanks to the constant() function:
// src/AppBundle/Entity/Post.php
namespace AppBundle\Entity;
class Post
{
const NUM_ITEMS = 10;
// ...
}
And use this constant in template twig:
Displaying the {{ constant('NUM_ITEMS', post) }} most recent results.
Here the link: http://symfony.com/doc/current/best_practices/configuration.html#constants-vs-configuration-options