summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/user/src/Hook/UserViewsExecutionHooks.php
blob: 7b5ec1ea7599518ae49ab6ac58b48d2b6669bfad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

namespace Drupal\user\Hook;

use Drupal\views\ViewExecutable;
use Drupal\Core\Hook\Attribute\Hook;

/**
 * Hook implementations for user.
 */
class UserViewsExecutionHooks {

  /**
   * Implements hook_views_query_substitutions().
   *
   * Allow replacement of current user ID so we can cache these queries.
   */
  #[Hook('views_query_substitutions')]
  public function viewsQuerySubstitutions(ViewExecutable $view): array {
    return ['***CURRENT_USER***' => \Drupal::currentUser()->id()];
  }

}