Adding PHP Function to Symfony ExpressionLanguage, The Simple Way 👌

JoliCode - JoliCodeBlog - 26/03
Today I want to share a quick tip for Symfony users ✌️. When you use the ExpressionLanguage component you get a context: some variables and some functions. Those functions are not the same everywhere. For example when using the validation constraint Expression: #[Assert\Expression(

Today I want to share a quick tip for Symfony users ✌️. When you use the ExpressionLanguage component you get a context: some variables and some functions.

Those functions are not the same everywhere. For example when using the validation constraint Expression:

#[Assert\Expression( "is_valid(this.getCategory()) or is_valid(this.getSection())", message: 'Bad category!', )] class BlogPost { // ... }

You get a custom ExpressionLanguage service, defined like this:

// The langua...
[Courte citation de 8% de l'article original]
Loading...