You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some issues when I use the excludeIf option with a large expression in the annotation.
I want to split it to see the entire expression without scrolling horizontally.
Example
/** * @Hateoas\Relation( * name="foo" * embedded=@Hateoas\Embedded( * "expr(object.getA().getB().getC().getD()", * exclusion=@Hateoas\Exclusion( * groups={"public"}, * excludeIf="expr(not object.getA() or not object.getA().getB() or not object.getA().getB().getC())" * ) * ) * ) */class Group
The CheckExpressionTrait::checkExpression method gets the expression like this expr(not object.getA()\n or not object.getA().getB()\n or not object.getA().getB().getC()).
The Symfony Expression Language component will replace all the \n with whitespaces, but the regular expression is not taking the entire expression.
if (is_string($exp) && preg_match('/expr\((?P<expression>.+)\)/', $exp, $matches)) {
So the matching in the expression group is not object.getA(
I am not sure if the regular expression can be updated to use "single line" flag, /expr\((?P<expression>.+)\)/s, so dots matches newline.
Thanks
The text was updated successfully, but these errors were encountered:
ixarlie
changed the title
Allow multiple lines in a excludeIf expression annotation
Allow multiple lines in excludeIf expression annotation
Jan 14, 2021
I have some issues when I use the
excludeIf
option with a large expression in the annotation.I want to split it to see the entire expression without scrolling horizontally.
Example
The
CheckExpressionTrait::checkExpression
method gets the expression like thisexpr(not object.getA()\n or not object.getA().getB()\n or not object.getA().getB().getC())
.The Symfony Expression Language component will replace all the
\n
with whitespaces, but the regular expression is not taking the entire expression.https://github.com/willdurand/Hateoas/blob/master/src/Configuration/Metadata/Driver/CheckExpressionTrait.php#L25
So the matching in the expression group is
not object.getA(
I am not sure if the regular expression can be updated to use "single line" flag,
/expr\((?P<expression>.+)\)/s
, so dots matches newline.Thanks
The text was updated successfully, but these errors were encountered: