Skip to content

[ExpressionLanguage] Document ExpressionFunction::fromPhp #7517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 28, 2017
Merged
Changes from 2 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
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 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');

It allows namespaced PHP function where second parameter must be defined to name expression::
Copy link
Member

Choose a reason for hiding this comment

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

[...] where the second [...]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


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