ViewsViewsExecutionHooks.php

Namespace

Drupal\views\Hook

File

core/modules/views/src/Hook/ViewsViewsExecutionHooks.php

View source
<?php

namespace Drupal\views\Hook;

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

/**
 * Hook implementations for views.
 */
class ViewsViewsExecutionHooks {
    
    /**
     * Implements hook_views_query_substitutions().
     *
     * Makes the following substitutions:
     * - Current time.
     * - Drupal version.
     * - Special language codes; see
     *   \Drupal\views\Plugin\views\PluginBase::listLanguages().
     */
    public function viewsQuerySubstitutions(ViewExecutable $view) {
        $substitutions = [
            '***CURRENT_VERSION***' => \Drupal::VERSION,
            '***CURRENT_TIME***' => \Drupal::time()->getRequestTime(),
        ] + PluginBase::queryLanguageSubstitutions();
        return $substitutions;
    }
    
    /**
     * Implements hook_views_form_substitutions().
     */
    public function viewsFormSubstitutions() {
        $select_all = [
            '#type' => 'checkbox',
            '#default_value' => FALSE,
            '#attributes' => [
                'class' => [
                    'action-table-select-all',
                ],
            ],
        ];
        return [
            '<!--action-bulk-form-select-all-->' => \Drupal::service('renderer')->render($select_all),
        ];
    }

}

Classes

Title Deprecated Summary
ViewsViewsExecutionHooks Hook implementations for views.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.