我有一个代码可以检查树枝模板中的一些实体常量:
{% if logRecord.status is constant('App\\DealBundle\\Entity\\Deal::DEAL_STATE_MONEY_RESERVED') %}
但是每次都用这么长的类名,实在是太尴尬了。有没有办法在 twig 中创建命名空间别名?就像是:
{% use App\\DealBundle\\Entity\\Deal %}
{% if logRecord.status is constant('Deal::DEAL_STATE_MONEY_RESERVED') %}
或者我总是需要写完整的班级名称?