Skip to content

Instantly share code, notes, and snippets.

@mecmartini
Created November 5, 2020 15:24
Show Gist options
  • Save mecmartini/d932814b0e37a163977342a068ff6314 to your computer and use it in GitHub Desktop.
Save mecmartini/d932814b0e37a163977342a068ff6314 to your computer and use it in GitHub Desktop.
Drupal 8 entity query with or condition and entity reference field
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
$orGroup = \Drupal::entityQuery('node')->orConditionGroup()
->condition('type', 'page');
->condition('type', 'article')
->condition('type', 'landing');
$result = \Drupal::entityQuery('node')
->status(1)
->condition($orGroup)
->condition('comment:status', CommentItemInterface::OPEN)
->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment