symfony/symfony — pull request #10512 by mgiustiniani (2014-03-22 11:54:50+00:00)
Title: Extended Expression Language in a routing component

A new expression language engine in a routing component can't extended with new custom functions, in my project i need custom function in a route condition.

with this patch and a custom compilerpass in my bundle i can added my custom function (version_compare of php).

```php
class OverrideServiceCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container){

$definition = $container->getDefinition('router.default');

$definition->addMethodCall('setExpressionLanguage',array(new Reference('examplebundle.routing_expression_language')));

}
}
```
a code of examplebundle.routing_expression_language is here:
```php
class NewExpressionLanguage extends ExpressionLanguage
{

protected function registerFunctions()
{
parent::registerFunctions();

$this->register('compare', function ($version1, $version2, $operator) {
return sprintf('version_compare(%s, %s, %s)', $version1, $version2, $operator);
}, function (array $values, $version1, $version2, $operator) {
return version_compare($version1, $version2, $operator);
});
}

}
```