How to access class constants in Twig?
Just to save your time. If you need to access class constants under namespace, use
{{ constant('Acme\\DemoBundle\\Entity\\Demo::MY_CONSTANT') }}
{% if var == constant('Namespace\\Entity::TYPE_PERSON') %}
{# or #}
{% if var is constant('Namespace\\Entity::TYPE_PERSON') %}
See documentation for the constant
function and the constant
test.