Skip to content
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

Use Symfony's ExpressionLanguage component for filters #100

Merged
merged 1 commit into from
Jun 14, 2021

Conversation

ogizanagi
Copy link
Member

@ogizanagi ogizanagi commented Jun 11, 2021

Fixes #99. A bit more verbose, but waaay more powerful and extensible.

  See https://symfony.com/doc/current/components/expression_language/syntax.html
  The current item is referred using "data", "d" or "_":

      php bin/console debug:stenope:content "App\Model\Author" --filter=data.active
      php bin/console debug:stenope:content "App\Model\Author" --filter=d.active
      php bin/console debug:stenope:content "App\Model\Author" --filter=_.active

  Negation:

      php bin/console debug:stenope:content "App\Model\Author" --filter='not d.active'
      php bin/console debug:stenope:content "App\Model\Author" --filter='!d.active'

  Contains:

      php bin/console debug:stenope:content "App\Model\Article" --filter='contains(_.slug, "symfony")'

  You can also use multiple filters at once:

      php bin/console debug:stenope:content "App\Model\Article" \
          --filter='not _.outdated' \
          --filter='contains(_.slug, "dev")' \
          --filter='"symfony" in _.tags' \
          --filter='_.date > date("2021-01-23")'

  Built-in functions are:

  * date
  * datetime
  * upper
  * lower
  * contains
  * starts_with
  * ends_with

Expressions can be used to filter using the ContentManager::getContents and in Twig as well.
New functions can be added using the stenope.expression_language_provider tag.


TODO

  • Fix & add more tests

@ogizanagi ogizanagi added the enhancement New feature or request label Jun 11, 2021
@ogizanagi ogizanagi requested a review from Tom32i June 11, 2021 15:34
@ogizanagi ogizanagi force-pushed the expr-language branch 3 times, most recently from 7fb9727 to dceebcf Compare June 14, 2021 08:21
Copy link
Collaborator

@Tom32i Tom32i left a comment

Choose a reason for hiding this comment

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

Very nice feature!

@@ -3,6 +3,7 @@

@import '~milligram/src/milligram';

@import './admonitions';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hidden feature 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

@ogizanagi ogizanagi merged commit d8ee8cc into master Jun 14, 2021
@ogizanagi ogizanagi deleted the expr-language branch June 14, 2021 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Symfony's ExpressionLanguage component to filter output of the debug command
2 participants