You are here

public function Flags::query in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 8 modules/cms_content_sync_views/src/Plugin/views/filter/Flags.php \Drupal\cms_content_sync_views\Plugin\views\filter\Flags::query()
  2. 2.1.x modules/cms_content_sync_views/src/Plugin/views/filter/Flags.php \Drupal\cms_content_sync_views\Plugin\views\filter\Flags::query()

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides InOperator::query

File

modules/cms_content_sync_views/src/Plugin/views/filter/Flags.php, line 75

Class

Flags
Provides a view filter to filter on the sync state entity.

Namespace

Drupal\cms_content_sync_views\Plugin\views\filter

Code

public function query() {
  $values = $this->value;
  $flags = 0;
  $flag_name_to_value = [
    'push_failed' => EntityStatus::FLAG_PUSH_FAILED,
    'push_failed_soft' => EntityStatus::FLAG_PUSH_FAILED_SOFT,
    'pull_failed_soft' => EntityStatus::FLAG_PULL_FAILED_SOFT,
    'pull_failed' => EntityStatus::FLAG_PULL_FAILED,
    'last_push_reset' => EntityStatus::FLAG_LAST_PUSH_RESET,
    'last_pull_reset' => EntityStatus::FLAG_LAST_PULL_RESET,
    'is_source_entity' => EntityStatus::FLAG_IS_SOURCE_ENTITY,
    'edit_override' => EntityStatus::FLAG_EDIT_OVERRIDE,
    'is_deleted' => EntityStatus::FLAG_DELETED,
  ];
  foreach ($values as $value) {
    $flags |= $flag_name_to_value[$value];
  }
  $this->query
    ->addWhereExpression($this->options['group'], '(cms_content_sync_entity_status.flags &' . $flags . ')> 0');
}