Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions components/expression_language/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ register.
}
}

.. tip::

You can create an expression function from a PHP function with the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"You can create ..." => "To create ..."

:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunction::fromPhp` static method::

ExpressionFunction::fromPhp('strtoupper');

Namespaced functions are supported, but they require a second argument to
define the name of the expression::

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

.. versionadded:: 3.3
The ``ExpressionFunction::fromPhp()`` method was introduced in Symfony 3.3.

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