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
After some years I realized that my previous answer is not really so good. I have created extension that solves problem better. It's published as open source.
https://github.com/dpolac/twig-const
It defines new Twig operator #
which let you access the class constant through any object of that class.
Use it like that:
{% if entity.type == entity#TYPE_PERSON %}