Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add fromPhp tip
  • Loading branch information
maidmaid committed Feb 21, 2017
commit 6d9af3764a0bb652d19cda24f78f8e02395a8f9f
11 changes: 11 additions & 0 deletions components/expression_language/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ register.
}
}

.. tip::

You can create an expression expression from a PHP function with the
:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunction::fromPhp` static method::

ExpressionFunction::fromPhp('strtoupper');

It allows namespaced PHP function where second parameter must be set to name expression::

ExpressionFunction::fromPhp('My\strtoupper', 'my_strtoupper');

You can register providers using
:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::registerProvider`
or by using the second argument of the constructor::
Expand Down