i'm trying to use class constant in a doctrine annotation, as explained here : http://doctrine-common.readthedocs.io/en/latest/reference/annotations.html#constants
for example, this works like a charm :
@MappableProperty(description=Company::ACTIVITY_NATURE_BIC)
But I don't want to parse a raw constant, I would like to concatenate it with a string.
what I would like to achieve is something like this :
@MappableProperty(description="Activity nature, for example Company::ACTIVITY_NATURE_BIC")
as expected, this doesn't work. Is constant concatenation impossible in doctrine annotation ?
EDIT : after some research, this is impossible to parse both string and constants at the same time right now. might be implemented in the future.
One can't use constants concatenation in annotations, but one can concatenate strings and constants into another class constant and then use it in the annotation.
For instance:
class Company {
public const ACTIVITY_NATURE_BIC = "[...]";
public const ACTIVITY_NATURE_DESCRIPTION = "Activity nature, for example ".self::ACTIVITY_NATURE_BIC;
/** @MappableProperty(description=Company::ACTIVITY_NATURE_DESCRIPTION) */
private $activityNature;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With