I have a few class constants in my entity class, e.g.:
class Entity {
const TYPE_PERSON = 0;
const TYPE_COMPANY = 1;
}
In normal PHP I often do if($var == Entity::TYPE_PERSON)
and I would like to do this kind of stuff in Twig. Is it possible?
Just to save your time. If you need to access class constants under namespace, use
{{ constant('Acme\\DemoBundle\\Entity\\Demo::MY_CONSTANT') }}