Skip to content

Commit

Permalink
bug #4637 fixed StringExpressionLanguageProvider code example #4636 (…
Browse files Browse the repository at this point in the history
…danieleorler)

This PR was squashed before being merged into the 2.6 branch (closes #4637).

Discussion
----------

fixed StringExpressionLanguageProvider code example #4636

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.6
| Fixed tickets | #4636

Commits
-------

33e0a7f fixed StringExpressionLanguageProvider code example #4636
  • Loading branch information
wouterj committed Dec 13, 2014
2 parents fc3e50b + 33e0a7f commit a2ea256
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions components/expression_language/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,20 @@ register.
class StringExpressionLanguageProvider implements ExpressionFunctionProviderInterface
{
return array(
new ExpressionFunction('lowercase', function ($str) {
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str);
}, function ($arguments, $str) {
if (!is_string($str)) {
return $str;
}
return strtolower($str);
});
);
public function getFunctions()
{
return array(
new ExpressionFunction('lowercase', function ($str) {
return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str);
}, function ($arguments, $str) {
if (!is_string($str)) {
return $str;
}
return strtolower($str);
}),
);
}
}
You can register providers using
Expand Down

0 comments on commit a2ea256

Please sign in to comment.