Skip to content
Snippets Groups Projects
Commit 7c61f4aa authored by catch's avatar catch
Browse files

Issue #1834184 by dawehner: Fixed Add basic views hooks to hook_hook_info().

parent e8fb3cea
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -1306,3 +1306,17 @@ function _field_create_entity_from_ids($ids) {
function field_reserved_columns() {
return array('deleted');
}
/**
* Implements hook_hook_info().
*/
function field_hook_info() {
$hooks['field_views_data'] = array(
'group' => 'views',
);
$hooks['field_views_data_alter'] = array(
'group' => 'views',
);
return $hooks;
}
<?php
/**
* @file
* Contains \Drupal\views\Tests\ViewsHooksTest.
*/
namespace Drupal\views\Tests;
/**
* Tests that views hooks are registered when defined in $module.views.inc.
*
* @see views_hook_info().
* @see field_hook_info().
*/
class ViewsHooksTest extends ViewUnitTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('views_test_data');
public static function getInfo() {
return array(
'name' => 'Views Hooks',
'description' => 'Tests that views hooks are registered when defined in $module.views.inc.',
'group' => 'Views',
);
}
/**
* Tests the hooks.
*/
public function testHooks() {
$hooks = &drupal_static(__FUNCTION__);
$views_hooks = array(
'views_data',
'views_data_alter',
'views_query_substitutions',
'views_form_substitutions',
'field_views_data',
'field_views_data_alter',
);
foreach ($views_hooks as $hook) {
$implementations = module_implements($hook);
$this->assertTrue(in_array('views_test_data', $implementations), format_string('The hook @hook was registered.', array('@hook' => $hook)));
// Reset the module implements cache, so we ensure that the .views.inc
// file is loaded actively.
unset($hooks['implementations']);
}
}
}
......@@ -19,13 +19,6 @@ function views_test_data_permission() {
);
}
/**
* Implements hook_views_data().
*/
function views_test_data_views_data() {
return state()->get('views_test_data_views_data');
}
function views_test_data_test_static_access_callback($access) {
return $access;
}
......@@ -34,7 +27,7 @@ function views_test_data_test_dynamic_access_callback($access, $argument1, $argu
return $access && $argument1 == state()->get('test_dynamic_access_argument1') && $argument2 == state()->get('test_dynamic_access_argument2');
}
/**+
/**
* Access callback for the generic handler test.
*
* @return bool
......
......@@ -20,3 +20,45 @@ function views_test_data_views_analyze(ViewExecutable $view) {
return $ret;
}
/**
* Implements hook_views_data().
*/
function views_test_data_views_data() {
return state()->get('views_test_data_views_data');
}
/**
* Implements hook_views_data_alter().
*/
function views_test_data_views_data_alter(&$data) {
}
/**
* Implements hook_views_query_substitutions().
*/
function views_test_data_views_query_substitutions() {
}
/**
* Implements hook_views_form_substitutions().
*/
function views_test_data_views_form_substitutions() {
}
/**
* Implements hook_field_views_data().
*/
function views_test_data_field_views_data($field) {
}
/**
* Implements hook_field_views_data_alter().
*/
function views_test_data_field_views_data_alter(&$data, $field, $module) {
}
......@@ -885,6 +885,9 @@ function views_hook_info() {
$hooks['views_analyze'] = array(
'group' => 'views',
);
$hooks['views_data_alter'] = array(
'group' => 'views',
);
return $hooks;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment