Class Drupal\user\Hook\UserViewsExecutionHooks - Source Code

Primary tabs

API docs: https://api.drupal.org/api/drupal/core!modules!user!src!Hook!UserViewsExecutionHooks.php/11.3.x

GitLab: https://git.drupalcode.org/project/drupal/-/blob/11.3.x/core/modules/user/src/Hook/UserViewsExecutionHooks.php

Location: /core/modules/user/src/Hook/UserViewsExecutionHooks.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()];
  }

}