class ViewsTestDataHooks

Hook implementations for views_test_data.

Hierarchy

Expanded class hierarchy of ViewsTestDataHooks

File

core/modules/views/tests/modules/views_test_data/src/Hook/ViewsTestDataHooks.php, line 14

Namespace

Drupal\views_test_data\Hook
View source
class ViewsTestDataHooks {
    
    /**
     * Implements hook_form_BASE_FORM_ID_alter().
     */
    public function formViewsFormTestFormMultipleDefaultAlter(&$form, FormStateInterface $form_state, $form_id) : void {
        \Drupal::messenger()->addStatus(t('Test base form ID with Views forms and arguments.'));
    }
    
    /**
     * Implements hook_ENTITY_TYPE_update() for the 'view' entity type.
     */
    public function viewUpdate(ViewEntityInterface $view) {
        // Use state to keep track of how many times a file is saved.
        $view_save_count = \Drupal::state()->get('views_test_data.view_save_count', []);
        $view_save_count[$view->id()] = isset($view_save_count[$view->id()]) ? $view_save_count[$view->id()] + 1 : 1;
        \Drupal::state()->set('views_test_data.view_save_count', $view_save_count);
    }

}

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