public function SyncState::query in CMS Content Sync 2.0.x
Same name in this branch
- 2.0.x modules/cms_content_sync_views/src/Plugin/views/filter/SyncState.php \Drupal\cms_content_sync_views\Plugin\views\filter\SyncState::query()
- 2.0.x modules/cms_content_sync_views/src/Plugin/views/field/SyncState.php \Drupal\cms_content_sync_views\Plugin\views\field\SyncState::query()
Same name and namespace in other branches
- 8 modules/cms_content_sync_views/src/Plugin/views/filter/SyncState.php \Drupal\cms_content_sync_views\Plugin\views\filter\SyncState::query()
- 2.1.x modules/cms_content_sync_views/src/Plugin/views/filter/SyncState.php \Drupal\cms_content_sync_views\Plugin\views\filter\SyncState::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/ SyncState.php, line 84
Class
- SyncState
- Provides a view filter to filter on the sync state entity.
Namespace
Drupal\cms_content_sync_views\Plugin\views\filterCode
public function query() {
$values = $this->value;
$operator = $this->operator;
$entity_table = $this
->ensureMyTable();
// Join the entity status table.
$configuration_entity_status = [
'table' => 'cms_content_sync_entity_status',
'field' => 'entity_uuid',
'left_table' => $entity_table,
'left_field' => 'uuid',
'operator' => '=',
];
$join_entity_status = Views::pluginManager('join')
->createInstance('standard', $configuration_entity_status);
$this->query
->addRelationship('cms_content_sync_entity_status', $join_entity_status, $entity_table);
// Add filter.
// @todo Provide more operators.
if ($operator == 'in') {
if (in_array('pushed', $values)) {
$this->query
->addWhere('', 'cms_content_sync_entity_status.last_export', '', 'IS NOT NULL');
}
if (in_array('pushed_update', $values)) {
$this->query
->addWhere('', 'cms_content_sync_entity_status.last_export', '', 'IS NOT NULL');
// @todo This is not working correctly with translations.
$this->query
->addWhereExpression($this->options['group'], 'cms_content_sync_entity_status.last_export != ' . $entity_table . '_field_data' . '.changed');
}
if (in_array('pulled', $values)) {
$this->query
->addWhere('', 'cms_content_sync_entity_status.last_import', '', 'IS NOT NULL');
}
if (in_array('overridden_locally', $values)) {
$this->query
->addWhereExpression($this->options['group'], 'cms_content_sync_entity_status.flags&' . EntityStatus::FLAG_EDIT_OVERRIDE . '=' . EntityStatus::FLAG_EDIT_OVERRIDE);
}
}
}