FZE*_*FZE 3 php annotations metaprogramming symfony
Constants一般来说,我在所有基于注释的地方使用,例如annotations, route and assert annotations,但在 Assert\Expression 中它会抛出Variable "EntityInterface" is not valid around position 26.
这是一个错误还是一个特殊的罕见情况?
<?php
/**
* @var string
*
* @ORM\Column(name="id_number", type="string", length=11, nullable=true)
* @Assert\Expression(
* "this.getNationality() == EntityInterface::COUNTRY_DEFAULT_VALUE and value != null",
* message = "form.user.validation.id_number.blank",
* groups = {"personal_info"}
* )
* @Assert\Regex(
* pattern="/^([\d]{11})$/",
* match=true,
* message="form.user.validation.id_number.regex",
* groups = {"personal_info"}
* )
*/
private $idNumber;
Run Code Online (Sandbox Code Playgroud)
尝试使用
/**
* @ORM\Column(name="id_number", type="string", length=11, nullable=true)
* @Assert\Expression(
* "this.getNationality() == constant('EntityInterface::COUNTRY_DEFAULT_VALUE') and value != null",
* message = "form.user.validation.id_number.blank",
* groups = {"personal_info"}
* )
*/
Run Code Online (Sandbox Code Playgroud)
相反(省略了示例的部分内容以集中在constant()此处使用)。
作为参考,请参阅
| 归档时间: |
|
| 查看次数: |
4136 次 |
| 最近记录: |