我有一段代码,它在Twig模板中检查一些实体常量:
{% 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') %}
或者我总是需要编写完整的类名吗?
if logRecord.status is state('reserved')
? - Maerlyn