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

8.0.x
Alex Pott 2014-10-10 13:06:14 +01:00
parent 85145ba9e3
commit 695afed505
3 changed files with 155 additions and 0 deletions

View File

@ -60,6 +60,7 @@ class ViewsHandlerManager extends DefaultPluginManager implements FallbackPlugin
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;

View File

@ -0,0 +1,58 @@
<?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();
}
}

View File

@ -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';
}
/**
* @}
*/