Skip to content

Instantly share code, notes, and snippets.

@bdunogier
Last active August 29, 2015 13:57
Show Gist options
  • Save bdunogier/9627191 to your computer and use it in GitHub Desktop.
Save bdunogier/9627191 to your computer and use it in GitHub Desktop.
<?php
// "Simple" query (e.g. no logical operations)
// is_class( article, blog_post ) AND parent_location_id( 4 ) AND attr_enabled = true AND attr_publishing_date = <DATE>
$queryBuilder
->contentTypeIdentifier()->in( 'article', 'blog_post' )
->parentLocationId()->eq( 2 )
->checkboxField( 'enabled' )->isFalse()
->dateField( 'publishing_date' )->before( 'last monday' )
->sortBy()
->datePublished()->descending()
->contentName()->ascending();
// "Complex" query (e.g. with logical operations)
// ( ( is_class( article, blog ) AND parent_location_id( 2 ) ) OR attr_can_syndicate == true ) AND published > 10 days
$queryBuilder
->or(
$queryBuilder->expr()->and(
$queryBuilder->expr()
->contentTypeIdentifier()->in( 'article', 'blog' )
->parentLocationId()->eq( 2 )
)
->checkboxField( 'can_syndicate' )->isTrue()
)
->wasCreated()->before( '10 days ago' )
->sortBy()->datePublished()->ascending();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment