function multiversion_views_query_alter in Multiversion 8
Same name and namespace in other branches
- 8.2 multiversion.module \multiversion_views_query_alter()
Implements hook_views_query_alter().
Parameters
\Drupal\views\ViewExecutable $view: The view object about to be processed.
QueryPluginBase $query: The query plugin object for the query.
File
- ./
multiversion.module, line 432
Code
function multiversion_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
// Add a new filter for default core views, it will filter deleted content.
$views_ids = [
'content',
'frontpage',
'comments_recent',
'content_recent',
'taxonomy_term',
'glossary',
'archive',
'block_content',
'poll_admin',
'poll_list',
'media_library',
];
if (in_array($view
->id(), $views_ids)) {
/** @var \Drupal\multiversion\MultiversionManagerInterface $manager */
$manager = \Drupal::service('multiversion.manager');
$entity_type = $view
->getBaseEntityType();
if (!$manager
->isEnabledEntityType($entity_type)) {
return;
}
$base_table = $view->storage
->get('base_table');
$view->query->where[1]['conditions'][] = [
'field' => $base_table . '._deleted',
'value' => FALSE,
'operator' => '=',
];
$view->query->where[1]['conditions'][] = [
'field' => $base_table . '.workspace',
'value' => multiversion_get_active_workspace_id(),
'operator' => '=',
];
}
}