function view_unpublished_views_query_substitutions in view_unpublished 8
Same name and namespace in other branches
- 6 view_unpublished.module \view_unpublished_views_query_substitutions()
- 7 view_unpublished.module \view_unpublished_views_query_substitutions()
Implements hook_views_query_substitutions().
File
- ./
view_unpublished.views_execution.inc, line 14 - Provide views runtime hooks for view_unpublished.module.
Code
function view_unpublished_views_query_substitutions(ViewExecutable $view) {
$account = \Drupal::currentUser();
$substitutions = [];
foreach (NodeType::loadMultiple() as $type) {
$type_id = $type
->id();
$substitutions["***VIEWUNPUBLISHED_TYPE_{$type_id}***"] = (int) $account
->hasPermission('view any unpublished ' . $type_id . ' content');
}
$substitutions["***VIEWUNPUBLISHED_ANY***"] = (int) $account
->hasPermission('view any unpublished content');
return $substitutions;
}