Skip to content
Snippets Groups Projects
Commit b604f99c authored by Daniel Wehner's avatar Daniel Wehner Committed by Tim Plunkett
Browse files

Issue #1708404 by damiankloip, dawehner, tim.plunkett: ViewsDiscovery isn't necessary.

parent 3abb68e9
Branches
Tags
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
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Discovery\ViewsDiscovery.
*/
namespace Drupal\views\Plugin\Discovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
/**
* Discovery interface which supports the hook_views_plugins mechanism.
*/
class ViewsDiscovery extends AnnotatedClassDiscovery {
public function getDefinitions() {
$definitions = parent::getDefinitions();
foreach ($definitions as $definition) {
// @todo: Allow other modules to write views plugins
$module_dir = $module = 'views';
// Setup automatic path/file finding for theme registration
if ($module_dir == 'views') {
$theme_path = drupal_get_path('module', $module_dir) . '/theme';
$theme_file = 'theme.inc';
$path = drupal_get_path('module', $module_dir) . '/plugins';
}
else {
$theme_path = $path = drupal_get_path('module', $module_dir);
$theme_file = "$module.views.inc";
}
if (!isset($definition['module'])) {
$definition['module'] = $module_dir;
}
if (!isset($definition['theme path'])) {
$definition['theme path'] = $theme_path;
}
if (!isset($definition['theme file'])) {
$definition['theme file'] = $theme_file;
}
if (!isset($definition['path'])) {
$definition['path'] = $path;
}
if (!isset($definition['parent'])) {
$definition['parent'] = 'parent';
}
// merge the new data in
$definitions[$definition['id']] = $definition;
}
return $definitions;
}
}
......@@ -9,7 +9,7 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugin\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
class ViewsPluginManager extends PluginManagerBase {
......@@ -21,11 +21,56 @@ class ViewsPluginManager extends PluginManagerBase {
*/
protected $type;
/**
* A list of Drupal core modules.
*
* @var array
*/
protected $coreModules = array();
public function __construct($type) {
// @todo Remove this hack in http://drupal.org/node/1708404.
views_init();
$this->type = $type;
$this->discovery = new CacheDecorator(new ViewsDiscovery('views', $this->type), 'views:' . $this->type, 'cache');
$this->discovery = new CacheDecorator(new AnnotatedClassDiscovery('views', $this->type), 'views:' . $this->type, 'views');
$this->factory = new DefaultFactory($this->discovery);
$this->coreModules = views_core_modules();
}
/**
* Overrides Drupal\Component\Plugin\PluginManagerBase::processDefinition().
*/
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
// If someone adds an invalid plugin ID, don't provide defaults.
// views_get_plugin() will then don't createInstance.
if (empty($definition)) {
return;
}
$module = isset($definition['module']) ? $definition['module'] : 'views';
// If this module is a core module, use views as the module directory.
$module_dir = in_array($module, $this->coreModules) ? 'views' : $module;
// Setup automatic path/file finding for theme registration.
if ($module_dir == 'views') {
$theme_path = drupal_get_path('module', $module_dir) . '/theme';
$theme_file = 'theme.inc';
}
else {
$theme_path = $path = drupal_get_path('module', $module_dir);
$theme_file = "$module.views.inc";
}
$definition += array(
'module' => $module_dir,
'theme path' => $theme_path,
'theme file' => $theme_file,
'parent' => 'parent',
);
}
}
......@@ -16,6 +16,13 @@ class ArgumentDefaultTest extends ViewsSqlTest {
protected $profile = 'standard';
/**
* A random string used in the default views.
*
* @var string
*/
protected $random;
public static function getInfo() {
return array(
'name' => 'Argument default',
......@@ -34,7 +41,6 @@ public function setUp() {
* Tests the use of a default argument plugin that provides no options.
*/
function testArgumentDefaultNoOptions() {
module_enable(array('views_test'));
$admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
$this->drupalLogin($admin_user);
......
......@@ -207,7 +207,7 @@ protected function viewUpgradeImport() {
$handler->display->display_options["exposed_form"]["type"] = "basic";
$handler->display->display_options["pager"]["type"] = "some";
$handler->display->display_options["pager"]["options"]["items_per_page"] = 5;
$handler->display->display_options["style_plugin"] = "list";
$handler->display->display_options["style_plugin"] = "html_list";
$handler->display->display_options["row_plugin"] = "fields";
/* Relationship: Comment: Node */
$handler->display->display_options["relationships"]["nid"]["id"] = "nid";
......@@ -242,7 +242,7 @@ protected function viewUpgradeImport() {
$handler = $view->new_display("page", "Page", "page");
$handler->display->display_options["defaults"]["items_per_page"] = FALSE;
$handler->display->display_options["defaults"]["style_plugin"] = FALSE;
$handler->display->display_options["style_plugin"] = "list";
$handler->display->display_options["style_plugin"] = "html_list";
$handler->display->display_options["defaults"]["style_options"] = FALSE;
$handler->display->display_options["defaults"]["row_plugin"] = FALSE;
$handler->display->display_options["row_plugin"] = "fields";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment