Hi!

Symfony have one powerfull component to create Rules in base a compiled "rules" for example

  $rules->setExpression("node.getType() == 'product' and node.getProduct().getPrice() > 50");
  $rules->setActionEvents([...]);

I think what this component could be provide more flexibility because We can create a "Rules Language" based on the Drupal Framework.

This component together with Annotations could be provide a new functionality in a Drupal framework.

/**
* Rules("user.getRole() == 'anon'", action="RedirectResponse('/login')")
*/
class MyController
{
  //...
}

What think about this?

[*] http://symfony.com/doc/current/components/expression_language/index.html
[*] http://jwage.com/post/76799775984/using-the-symfony-expression-language-...
[*] http://blog.servergrove.com/2014/04/07/symfony2-components-overview-expr...

Comments

fago’s picture

Yeah, I had a look at the expression language already. It must say it looks very interesting and the existing integration possibilities with e.g. validation constraints or access for routes seem useful. However, here are some concerns:

  • It does not cover actions - we do need syntax for having actions and return variables for providing those back.
  • While it's easy to write expressions, we cannot expose that to site builders without loosing access control or even control of the code flow, as it's possible to invoke methods with expression language.
  • I'm not sure it's properly extensible with new kind of nodes even? Rules is by design extensible, i.e. modules can add new language constructs.
  • It looks like expression language could give us a good framework for generating PHP code, that said I'm not sure Rules expressions should be tightly coupled to generate PHP code. I could see us adding Rules expression targeted to JS in future which get compiled to JS code.

Lastly, we have to focus on bringing Rules 8.x out of the door asap. Thus, if building upon it makes things significantly more complex it's out of scope for us as we'll probably lack the resources.

klausi’s picture

Status: Active » Closed (won't fix)

We are not going to use Symfony Expression Language for now.