Commit 695afed5 authored by alexpott's avatar alexpott

Issue #2341385 by damiankloip: Fixed No alter hooks are invoked for views...

Issue #2341385 by damiankloip: Fixed No alter hooks are invoked for views handler plugin definitions.
parent 85145ba9
......@@ -60,6 +60,7 @@ public function __construct($handler_type, \Traversable $namespaces, ViewsData $
parent::__construct("Plugin/views/$handler_type", $namespaces, $module_handler, $plugin_interface, $plugin_definition_annotation_name);
$this->setCacheBackend($cache_backend, "views:$handler_type", array('extension', 'extension:views'));
$this->alterInfo('views_plugins_' . $handler_type);
$this->viewsData = $views_data;
$this->handlerType = $handler_type;
......
<?php
/**
* @file
* Contains \Drupal\Tests\views\Unit\ViewsHandlerManagerTest.
*/
namespace Drupal\Tests\views\Unit;
use Drupal\Tests\UnitTestCase;
use Drupal\views\Plugin\ViewsHandlerManager;
/**
* Tests the ViewsHandlerManager class.
*
* @group views
*
* @coversDefaultClass \Drupal\views\Plugin\ViewsHandlerManager
*/
class ViewsHandlerManagerTest extends UnitTestCase {
/**
* @var \Drupal\views\Plugin\ViewsHandlerManager
*/
protected $handlerManager;
/**
* @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $moduleHandler;
/**
* {@inheritdoc}
*/
public function setUp() {
$views_data = $this->getMockBuilder('Drupal\views\ViewsData')
->disableOriginalConstructor()
->getMock();
$cache_backend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->handlerManager = new ViewsHandlerManager('test', new \ArrayObject(array()), $views_data, $cache_backend, $this->moduleHandler);
}
/**
* Tests that hook_views_plugins_TYPE_alter() is invoked for a handler type.
*
* @covers ::__construct
* @covers ::getDefinitions
*/
public function testAlterHookInvocation() {
$this->moduleHandler->expects($this->once())
->method('alter')
->with('views_plugins_test', array());
$this->handlerManager->getDefinitions();
}
}
......@@ -1081,6 +1081,102 @@ function hook_views_plugins_wizard_alter(array &$plugins) {
$plugins['node_revision']['title'] = t('Node revision wizard');
}
/**
* Modify the list of available views area handler plugins.
*
* This hook may be used to modify handler properties after they have been
* specified by other modules.
*
* @param array $plugins
* An array of all the existing handler definitions, passed by reference.
*
* @see \Drupal\views\Plugin\ViewsHandlerManager
*/
function hook_views_plugins_area_alter(array &$plugins) {
// Change the 'title' handler class.
$plugins['title']['class'] = 'Drupal\\example\\ExampleClass';
}
/**
* Modify the list of available views argument handler plugins.
*
* This hook may be used to modify handler properties after they have been
* specified by other modules.
*
* @param array $plugins
* An array of all the existing handler definitions, passed by reference.
*
* @see \Drupal\views\Plugin\ViewsHandlerManager
*/
function hook_views_plugins_argument_alter(array &$plugins) {
// Change the 'title' handler class.
$plugins['title']['class'] = 'Drupal\\example\\ExampleClass';
}
/**
* Modify the list of available views field handler plugins.
*
* This hook may be used to modify handler properties after they have been
* specified by other modules.
*
* @param array $plugins
* An array of all the existing handler definitions, passed by reference.
*
* @see \Drupal\views\Plugin\ViewsHandlerManager
*/
function hook_views_plugins_field_alter(array &$plugins) {
// Change the 'title' handler class.
$plugins['title']['class'] = 'Drupal\\example\\ExampleClass';
}
/**
* Modify the list of available views filter handler plugins.
*
* This hook may be used to modify handler properties after they have been
* specified by other modules.
*
* @param array $plugins
* An array of all the existing handler definitions, passed by reference.
*
* @see \Drupal\views\Plugin\ViewsHandlerManager
*/
function hook_views_plugins_filter_alter(array &$plugins) {
// Change the 'title' handler class.
$plugins['title']['class'] = 'Drupal\\example\\ExampleClass';
}
/**
* Modify the list of available views relationship handler plugins.
*
* This hook may be used to modify handler properties after they have been
* specified by other modules.
*
* @param array $plugins
* An array of all the existing handler definitions, passed by reference.
*
* @see \Drupal\views\Plugin\ViewsHandlerManager
*/
function hook_views_plugins_relationship_alter(array &$plugins) {
// Change the 'title' handler class.
$plugins['title']['class'] = 'Drupal\\example\\ExampleClass';
}
/**
* Modify the list of available views sort handler plugins.
*
* This hook may be used to modify handler properties after they have been
* specified by other modules.
*
* @param array $plugins
* An array of all the existing handler definitions, passed by reference.
*
* @see \Drupal\views\Plugin\ViewsHandlerManager
*/
function hook_views_plugins_sort_alter(array &$plugins) {
// Change the 'title' handler class.
$plugins['title']['class'] = 'Drupal\\example\\ExampleClass';
}
/**
* @}
*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment