📜  views_pre_view - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:07.640000             🧑  作者: Mango

代码示例1
function hook_views_pre_view(ViewExecutable $view, $display_id, array &$args) {

  // Modify contextual filters for my_special_view if user has 'my special permission'.
  $account = \Drupal::currentUser();
  if ($view
    ->id() == 'my_special_view' && $account
    ->hasPermission('my special permission') && $display_id == 'public_display') {
    $args[0] = 'custom value';
  }
}