RestTestViewsHooks.php

Namespace

Drupal\rest_test_views\Hook

File

core/modules/rest/tests/modules/rest_test_views/src/Hook/RestTestViewsHooks.php

View source
<?php

declare (strict_types=1);
namespace Drupal\rest_test_views\Hook;

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

/**
 * Hook implementations for rest_test_views.
 */
class RestTestViewsHooks {
    
    /**
     * Implements hook_views_post_execute().
     */
    public function viewsPostExecute(ViewExecutable $view) {
        // Attach a custom header to the test_data_export view.
        if ($view->id() === 'test_serializer_display_entity') {
            if ($value = \Drupal::state()->get('rest_test_views_set_header', FALSE)) {
                $view->getResponse()->headers
                    ->set('Custom-Header', $value);
            }
        }
    }

}

Classes

Title Deprecated Summary
RestTestViewsHooks Hook implementations for rest_test_views.

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