Commit 9ce08a3a authored by Dries's avatar Dries

Issue #1938030 by dawehner: Replace View's usage of drupal_container()->get()...

Issue #1938030 by dawehner: Replace View's usage of drupal_container()->get() with Drupal::service().
parent 7813d65e
......@@ -60,7 +60,7 @@ protected function setUp() {
public function testViewsData() {
$field_name = $this->field['field_name'];
$table_name = _field_sql_storage_tablename($this->field);
$data = drupal_container()->get('views.views_data')->get($table_name);
$data = $this->container->get('views.views_data')->get($table_name);
// Test that the expected data array is returned.
$expected = array('', '_value', '_format');
......
......@@ -12,6 +12,7 @@
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\views\Views;
/**
* A field that displays fieldapi fields.
......@@ -129,7 +130,7 @@ function get_base_table() {
$relationships = $this->view->display_handler->getOption('relationships');
if (!empty($relationships[$this->options['relationship']])) {
$options = $relationships[$this->options['relationship']];
$data = drupal_container()->get('views.views_data')->get($options['table']);
$data = Views::viewsData()->get($options['table']);
$this->base_table = $data[$options['field']]['relationship']['base'];
}
}
......
......@@ -11,6 +11,7 @@
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\relationship\RelationshipPluginBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\views\Views;
/**
* A relationship handlers which reverse entity references.
......@@ -40,7 +41,7 @@ public function query() {
$this->ensureMyTable();
// First, relate our base table to the current base table to the
// field, using the base table's id field to the field's column.
$views_data = drupal_container()->get('views.views_data')->get($this->table);
$views_data = Views::viewsData()->get($this->table);
$left_field = $views_data['table']['base']['field'];
$first = array(
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\views\Views;
use Drupal\views_ui\ViewUI;
use Drupal\views\ViewStorageInterface;
use Drupal\views\ViewExecutable;
......@@ -130,7 +131,7 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
public function get($property_name, $langcode = NULL) {
// Ensure that an executable View is available.
if ($property_name == 'executable' && !isset($this->{$property_name})) {
$this->set('executable', drupal_container()->get('views.executable')->get($this));
$this->set('executable', Views::executableFactory()->get($this));
}
return parent::get($property_name, $langcode);
......@@ -191,7 +192,7 @@ public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL) {
return FALSE;
}
$plugin = drupal_container()->get('plugin.manager.views.display')->getDefinition($plugin_id);
$plugin = Views::pluginManager('display')->getDefinition($plugin_id);
if (empty($plugin)) {
$plugin['title'] = t('Broken');
}
......@@ -308,7 +309,7 @@ public function &getDisplay($display_id) {
* An array of display types that this view includes.
*/
function getDisplaysList() {
$manager = drupal_container()->get('plugin.manager.views.display');
$manager = Views::pluginManager('display');
$displays = array();
foreach ($this->display as $display) {
$definition = $manager->getDefinition($display['display_plugin']);
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DerivativeInterface;
use Drupal\views\Views;
/**
* A derivative class which provides automatic wizards for all base tables.
......@@ -35,7 +36,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
* Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions().
*/
public function getDerivativeDefinitions(array $base_plugin_definition) {
$views_data = drupal_container()->get('views.views_data');
$views_data = Views::viewsData();
$base_tables = array_keys($views_data->fetchBaseTables());
$this->derivatives = array();
foreach ($base_tables as $table) {
......
......@@ -12,6 +12,7 @@
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\ViewExecutable;
use Drupal\Core\Database\Database;
use Drupal\views\Views;
abstract class HandlerBase extends PluginBase {
......@@ -645,7 +646,7 @@ public function getDateField() {
* @return Drupal\views\Plugin\views\join\JoinPluginBase
*/
public static function getTableJoin($table, $base_table) {
$data = drupal_container()->get('views.views_data')->get($table);
$data = Views::viewsData()->get($table);
if (isset($data['table']['join'][$base_table])) {
$join_info = $data['table']['join'][$base_table];
if (!empty($join_info['join_id'])) {
......@@ -671,7 +672,7 @@ public static function getTableJoin($table, $base_table) {
}
}
$join = drupal_container()->get('plugin.manager.views.join')->createInstance($id, $configuration);
$join = Views::pluginManager('join')->createInstance($id, $configuration);
return $join;
}
......@@ -690,10 +691,10 @@ public function getEntityType() {
// If the user has configured a relationship on the handler take that into
// account.
if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') {
$views_data = drupal_container()->get('views.views_data')->get($this->view->relationship->table);
$views_data = Views::viewsData()->get($this->view->relationship->table);
}
else {
$views_data = drupal_container()->get('views.views_data')->get($this->view->storage->get('base_table'));
$views_data = Views::viewsData()->get($this->view->storage->get('base_table'));
}
if (isset($views_data['table']['entity type'])) {
......
......@@ -11,6 +11,7 @@
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\HandlerBase;
use Drupal\views\Views;
/**
* @defgroup views_argument_handlers Views argument handlers
......@@ -301,7 +302,7 @@ public function buildOptionsForm(&$form, &$form_state) {
),
);
$plugins = drupal_container()->get('plugin.manager.views.argument_validator')->getDefinitions();
$plugins = Views::pluginManager('argument_validator')->getDefinitions();
foreach ($plugins as $id => $info) {
if (!empty($info['no_ui'])) {
continue;
......@@ -497,7 +498,7 @@ function default_actions($which = NULL) {
* default action is set to provide default argument.
*/
function default_argument_form(&$form, &$form_state) {
$plugins = drupal_container()->get('plugin.manager.views.argument_default')->getDefinitions();
$plugins = Views::pluginManager('argument_default')->getDefinitions();
$options = array();
$form['default_argument_skip_url'] = array(
......@@ -562,7 +563,7 @@ function default_argument_form(&$form, &$form_state) {
* default action is set to display one.
*/
function default_summary_form(&$form, &$form_state) {
$style_plugins = drupal_container()->get('plugin.manager.views.style')->getDefinitions();
$style_plugins = Views::pluginManager('style')->getDefinitions();
$summary_plugins = array();
$format_options = array();
foreach ($style_plugins as $key => $plugin) {
......@@ -1056,7 +1057,7 @@ function get_plugin($type = 'argument_default', $name = NULL) {
$options = $this->options[$options_name];
}
$plugin = drupal_container()->get("plugin.manager.views.$type")->createInstance($name);
$plugin = Views::pluginManager($type)->createInstance($name);
if ($plugin) {
$plugin->init($this->view, $this->displayHandler, $options);
......
......@@ -9,6 +9,7 @@
use Drupal\views\ViewExecutable;
use \Drupal\views\Plugin\views\PluginBase;
use Drupal\views\Views;
/**
* @defgroup views_display_plugins Views display plugins
......@@ -105,7 +106,7 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
$this->extender = array();
$extenders = views_get_enabled_display_extenders();
if (!empty($extenders)) {
$manager = drupal_container()->get('plugin.manager.views.display_extender');
$manager = Views::pluginManager('display_extender');
foreach ($extenders as $extender) {
$plugin = $manager->createInstance($extender);
if ($plugin) {
......@@ -798,13 +799,13 @@ public function getPlugin($type) {
// Query plugins allow specifying a specific query class per base table.
if ($type == 'query') {
$views_data = drupal_container()->get('views.views_data')->get($this->view->storage->get('base_table'));
$views_data = Views::viewsData()->get($this->view->storage->get('base_table'));
$name = isset($views_data['table']['base']['query_id']) ? $views_data['table']['base']['query_id'] : 'views_query';
}
// Plugin instances are stored on the display for re-use.
if (!isset($this->plugins[$type][$name])) {
$plugin = drupal_container()->get("plugin.manager.views.$type")->createInstance($name);
$plugin = Views::pluginManager($type)->createInstance($name);
// Initialize the plugin.
$plugin->init($this->view, $this, $options['options']);
......@@ -1148,7 +1149,7 @@ public function optionsSummary(&$categories, &$options) {
$pager_plugin = $this->getPlugin('pager');
if (!$pager_plugin) {
// default to the no pager plugin.
$pager_plugin = drupal_container()->get('plugin.manager.views.pager')->createInstance('none');
$pager_plugin = Views::pluginManager('pager')->createInstance('none');
}
$pager_str = $pager_plugin->summaryTitle();
......@@ -1214,7 +1215,7 @@ public function optionsSummary(&$categories, &$options) {
$access_plugin = $this->getPlugin('access');
if (!$access_plugin) {
// default to the no access control plugin.
$access_plugin = drupal_container()->get('plugin.manager.views.access')->createInstance('none');
$access_plugin = Views::pluginManager('access')->createInstance('none');
}
$access_str = $access_plugin->summaryTitle();
......@@ -1234,7 +1235,7 @@ public function optionsSummary(&$categories, &$options) {
$cache_plugin = $this->getPlugin('cache');
if (!$cache_plugin) {
// default to the no cache control plugin.
$cache_plugin = drupal_container()->get('plugin.manager.views.cache')->createInstance('none');
$cache_plugin = Views::pluginManager('cache')->createInstance('none');
}
$cache_str = $cache_plugin->summaryTitle();
......@@ -1280,7 +1281,7 @@ public function optionsSummary(&$categories, &$options) {
$exposed_form_plugin = $this->getPlugin('exposed_form');
if (!$exposed_form_plugin) {
// default to the no cache control plugin.
$exposed_form_plugin = drupal_container()->get('plugin.manager.views.exposed_form')->createInstance('basic');
$exposed_form_plugin = Views::pluginManager('exposed_form')->createInstance('basic');
}
$exposed_form_str = $exposed_form_plugin->summaryTitle();
......@@ -2154,7 +2155,7 @@ public function submitOptionsForm(&$form, &$form_state) {
case 'access':
$access = $this->getOption('access');
if ($access['type'] != $form_state['values']['access']['type']) {
$plugin = drupal_container()->get('plugin.manager.views.access')->createInstance($form_state['values']['access']['type']);
$plugin = Views::pluginManager('access')->createInstance($form_state['values']['access']['type']);
if ($plugin) {
$access = array('type' => $form_state['values']['access']['type']);
$this->setOption('access', $access);
......@@ -2177,7 +2178,7 @@ public function submitOptionsForm(&$form, &$form_state) {
case 'cache':
$cache = $this->getOption('cache');
if ($cache['type'] != $form_state['values']['cache']['type']) {
$plugin = drupal_container()->get('plugin.manager.views.cache')->createInstance($form_state['values']['cache']['type']);
$plugin = Views::pluginManager('cache')->createInstance($form_state['values']['cache']['type']);
if ($plugin) {
$cache = array('type' => $form_state['values']['cache']['type']);
$this->setOption('cache', $cache);
......@@ -2236,7 +2237,7 @@ public function submitOptionsForm(&$form, &$form_state) {
// the plugin.
$row = $this->getOption('row');
if ($row['type'] != $form_state['values'][$section]) {
$plugin = drupal_container()->get('plugin.manager.views.row')->createInstance($form_state['values'][$section]);
$plugin = Views::pluginManager('row')->createInstance($form_state['values'][$section]);
if ($plugin) {
$row = array('type' => $form_state['values'][$section]);
$this->setOption($section, $row);
......@@ -2253,7 +2254,7 @@ public function submitOptionsForm(&$form, &$form_state) {
// the plugin.
$style = $this->getOption('style');
if ($style['type'] != $form_state['values'][$section]) {
$plugin = drupal_container()->get('plugin.manager.views.style')->createInstance($form_state['values'][$section]);
$plugin = views::pluginManager('style')->createInstance($form_state['values'][$section]);
if ($plugin) {
$row = array('type' => $form_state['values'][$section]);
$this->setOption($section, $row);
......@@ -2288,7 +2289,7 @@ public function submitOptionsForm(&$form, &$form_state) {
case 'exposed_form':
$exposed_form = $this->getOption('exposed_form');
if ($exposed_form['type'] != $form_state['values']['exposed_form']['type']) {
$plugin = drupal_container()->get('plugin.manager.views.exposed_form')->createInstance($form_state['values']['exposed_form']['type']);
$plugin = Views::pluginManager('exposed_form')->createInstance($form_state['values']['exposed_form']['type']);
if ($plugin) {
$exposed_form = array('type' => $form_state['values']['exposed_form']['type'], 'options' => array());
$this->setOption('exposed_form', $exposed_form);
......@@ -2311,7 +2312,7 @@ public function submitOptionsForm(&$form, &$form_state) {
case 'pager':
$pager = $this->getOption('pager');
if ($pager['type'] != $form_state['values']['pager']['type']) {
$plugin = drupal_container()->get('plugin.manager.views.pager')->createInstance($form_state['values']['pager']['type']);
$plugin = Views::pluginManager('pager')->createInstance($form_state['values']['pager']['type']);
if ($plugin) {
// Because pagers have very similar options, let's allow pagers to
// try to carry the options over.
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\display;
use Drupal\views\Views;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
......@@ -61,7 +62,7 @@ public function executeHookMenu($callbacks) {
$access_plugin = $this->getPlugin('access');
if (!isset($access_plugin)) {
$access_plugin = drupal_container()->get("plugin.manager.views.access")->createInstance('none');
$access_plugin = Views::pluginManager('access')->createInstance('none');
}
// Get access callback might return an array of the callback + the dynamic
......
......@@ -28,7 +28,7 @@
* 'left_field' => 'field_a',
* 'operator' => '='
* );
* $join = drupal_container()->get('plugin.manager.views.join')->createInstance('standard', $configuration);
* $join = Views::pluginManager('join')->createInstance('standard', $configuration);
*
* Here is how you do complex joins:
*
......
......@@ -16,6 +16,7 @@
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
/**
* @todo.
......@@ -1444,7 +1445,7 @@ function execute(ViewExecutable $view) {
$count_query->addMetaData('view', $view);
if (empty($this->options['disable_sql_rewrite'])) {
$base_table_data = drupal_container()->get('views.views_data')->get($this->view->storage->get('base_table'));
$base_table_data = Views::viewsData()->get($this->view->storage->get('base_table'));
if (isset($base_table_data['table']['base']['access query tag'])) {
$access_tag = $base_table_data['table']['base']['access query tag'];
$query->addTag($access_tag);
......@@ -1542,7 +1543,7 @@ function execute(ViewExecutable $view) {
function get_entity_tables() {
// Start with the base table.
$entity_tables = array();
$views_data = drupal_container()->get('views.views_data');
$views_data = Views::viewsData();
$base_table_data = $views_data->get($this->view->storage->get('base_table'));
if (isset($base_table_data['table']['entity type'])) {
$entity_tables[$this->view->storage->get('base_table')] = array(
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\views\ViewExecutable;
use Drupal\Component\Annotation\Plugin;
use Drupal\views\Views;
/**
* Relationship handler that allows a groupwise maximum of the linked in table.
......@@ -93,7 +94,7 @@ public function buildOptionsForm(&$form, &$form_state) {
foreach ($sorts as $sort_id => $sort) {
$sort_options[$sort_id] = "$sort[group]: $sort[title]";
}
$base_table_data = drupal_container()->get('views.views_data')->get($this->definition['base']);
$base_table_data = Views::viewsData()->get($this->definition['base']);
$form['subquery_sort'] = array(
'#type' => 'select',
......@@ -219,7 +220,7 @@ function left_query($options) {
$temp_view->args[] = '**CORRELATED**';
// Add the base table ID field.
$views_data = drupal_container()->get('views.views_data')->get($this->definition['base']);
$views_data = Views::viewsData()->get($this->definition['base']);
$base_field = $views_data['table']['base']['field'];
$temp_view->addItem('default', 'field', $this->definition['base'], $this->definition['field']);
......@@ -341,7 +342,7 @@ function condition_namespace($string) {
*/
public function query() {
// Figure out what base table this relationship brings to the party.
$table_data = drupal_container()->get('views.views_data')->get($this->definition['base']);
$table_data = Views::viewsData()->get($this->definition['base']);
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
$this->ensureMyTable();
......@@ -379,7 +380,7 @@ public function query() {
else {
$id = 'subquery';
}
$join = drupal_container()->get('plugin.manager.views.join')->createInstance($id, $def);
$join = Views::pluginManager('join')->createInstance($id, $def);
// use a short alias for this:
$alias = $def['table'] . '_' . $this->table;
......
......@@ -12,6 +12,7 @@
use Drupal\views\Plugin\views\HandlerBase;
use Drupal\views\Join;
use Drupal\Component\Annotation\Plugin;
use Drupal\views\Views;
/**
* @defgroup views_relationship_handlers Views relationship handlers
......@@ -119,7 +120,7 @@ public function buildOptionsForm(&$form, &$form_state) {
*/
public function query() {
// Figure out what base table this relationship brings to the party.
$table_data = drupal_container()->get('views.views_data')->get($this->definition['base']);
$table_data = Views::viewsData()->get($this->definition['base']);
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
$this->ensureMyTable();
......@@ -144,7 +145,7 @@ public function query() {
else {
$id = 'standard';
}
$join = drupal_container()->get('plugin.manager.views.join')->createInstance($id, $def);
$join = Views::pluginManager('join')->createInstance($id, $def);
// use a short alias for this:
$alias = $def['table'] . '_' . $this->table;
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
/**
* @defgroup views_row_plugins Views row plugins
......@@ -73,7 +74,7 @@ public function buildOptionsForm(&$form, &$form_state) {
$relationship_handler = views_get_handler($relationship['table'], $relationship['field'], 'relationship');
// If this relationship is valid for this type, add it to the list.
$data = drupal_container()->get('views.views_data')->get($relationship['table']);
$data = Views::viewsData()->get($relationship['table']);
$base = $data[$relationship['field']]['relationship']['base'];
if ($base == $this->base_table) {
$relationship_handler->init($executable, $relationship);
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\sort;
use Drupal\Component\Annotation\Plugin;
use Drupal\views\Views;
/**
......@@ -52,7 +53,7 @@ public function query() {
'left_table' => $this->tableAlias,
'left_field' => $this->field . $i
);
$join = drupal_container()->get('plugin.manager.views.join')->createInstance('standard', $definition);
$join = Views::pluginManager('join')->createInstance('standard', $definition);
$menu_links = $this->query->add_table('menu_links', NULL, $join);
$this->query->add_orderby($menu_links, 'weight', $this->options['order']);
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\views\Plugin\Core\Entity\View;
use Drupal\views\Views;
use Drupal\views_ui\ViewUI;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\PluginBase;
......@@ -508,7 +509,7 @@ public static function getSelected($form_state, $parents, $default_value, $eleme
protected function build_form_style(array &$form, array &$form_state, $type) {
$style_form =& $form['displays'][$type]['options']['style'];
$style = $style_form['style_plugin']['#default_value'];
$style_plugin = drupal_container()->get("plugin.manager.views.style")->createInstance($style);
$style_plugin = Views::pluginManager('style')->createInstance($style);
if (isset($style_plugin) && $style_plugin->usesRowPlugin()) {
$options = $this->row_style_options();
$style_form['row_plugin'] = array(
......@@ -685,7 +686,7 @@ protected function build_display_options($form, $form_state) {
protected function alter_display_options(&$display_options, $form, $form_state) {
foreach ($display_options as $display_type => $options) {
// Allow style plugins to hook in and provide some settings.
$style_plugin = drupal_container()->get("plugin.manager.views.style")->createInstance($options['style']['type']);
$style_plugin = Views::pluginManager('style')->createInstance($options['style']['type']);
$style_plugin->wizard_submit($form, $form_state, $this, $display_options, $display_type);
}
}
......@@ -754,7 +755,7 @@ protected function default_display_options() {
// Add a least one field so the view validates and the user has a preview.
// The base field can provide a default in its base settings; otherwise,
// choose the first field with a field handler.
$data = drupal_container()->get('views.views_data')->get($this->base_table);
$data = Views::viewsData()->get($this->base_table);
if (isset($data['table']['base']['defaults']['field'])) {
$field = $data['table']['base']['defaults']['field'];
}
......@@ -836,10 +837,10 @@ protected function default_display_filters_user(array $form, array &$form_state)
}
}
}
$table_data = drupal_container()->get('views.views_data')->get($table);
$table_data = Views::viewsData()->get($table);
// If the 'in' operator is being used, map the values to an array.
$handler = $table_data[$bundle_key]['filter']['id'];
$handler_definition = drupal_container()->get('plugin.manager.views.filter')->getDefinition($handler);
$handler_definition = Views::pluginManager('filter')->getDefinition($handler);
if ($handler == 'in_operator' || is_subclass_of($handler_definition['class'], 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) {
$value = drupal_map_assoc(array($form_state['values']['show']['type']));
}
......@@ -922,7 +923,7 @@ protected function default_display_sorts_user($form, $form_state) {
// created from node, but the wizard type is another base table, make
// sure it is not added. This usually don't happen if you have js
// enabled.
$data = drupal_container()->get('views.views_data')->get($table);
$data = Views::viewsData()->get($table);
if (isset($data[$column]['sort'])) {
$sorts[$column] = array(
'id' => $column,
......
......@@ -10,6 +10,7 @@
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\HandlerBase;
use Drupal\views\Plugin\views\filter\InOperator;
use Drupal\views\Views;
/**
* Creates views with instances of all handlers...
......@@ -54,7 +55,7 @@ public static function getInfo() {
*/
public function testHandlers() {
$object_types = array_keys(ViewExecutable::viewsHandlerTypes());
foreach (drupal_container()->get('views.views_data')->get() as $base_table => $info) {
foreach (Views::viewsData()->get() as $base_table => $info) {
if (!isset($info['table']['base'])) {
continue;
}
......
......@@ -10,6 +10,8 @@
/**
* Tests basic functions from the Views module.
*/
use Drupal\views\Views;
class ModuleTest extends ViewUnitTestBase {
/**
......@@ -168,7 +170,7 @@ protected function formatViewOptions(array $views = array()) {
* Ensure that a certain handler is a instance of a certain table/field.
*/
function assertInstanceHandler($handler, $table, $field, $id) {
$table_data = drupal_container()->get('views.views_data')->get($table);
$table_data = Views::viewsData()->get($table);
$field_data = $table_data[$field][$id];
$this->assertEqual($field_data['id'], $handler->getPluginId());
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Views;
use Drupal\views_test_data\Plugin\views\filter\FilterTest as FilterPlugin;
/**
......@@ -59,7 +60,7 @@ protected function viewsData() {
*/
public function testFilterQuery() {
// Check that we can find the test filter plugin.
$plugin = drupal_container()->get("plugin.manager.views.filter")->createInstance('test_filter');
$plugin = Views::pluginManager('filter')->createInstance('test_filter');
$this->assertTrue($plugin instanceof FilterPlugin, 'Test filter plugin found.');
$view = views_get_view('test_filter');
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Views;
use Drupal\views_test_data\Plugin\views\join\JoinTest as JoinTestPlugin;
use Drupal\views\Plugin\views\join\JoinPluginBase;
......@@ -45,7 +46,7 @@ protected function setUp() {
parent::setUp();
// Add a join plugin manager which can be used in all of the tests.
$this->manager = drupal_container()->get('plugin.manager.views.join');
$this->manager = Views::pluginManager('join');
}
/**
......
......@@ -10,6 +10,8 @@
/**
* Tests the handling of displays in the UI, adding removing etc.
*/
use Drupal\views\Views;
class DisplayTest extends UITestBase {
/**
......@@ -212,7 +214,7 @@ public function testDisableDisplay() {
* Tests views_ui_views_plugins_display_alter is altering plugin definitions.
*/
public function testDisplayPluginsAlter() {
$definitions = drupal_container()->get('plugin.manager.views.display')->getDefinitions();
$definitions = Views::pluginManager('display')->getDefinitions();
$expected = array(
'parent path' => 'admin/structure/views/view',
......
......@@ -7,6 +7,7 @@
namespace Drupal\views;
use Drupal;
use Symfony\Component\HttpFoundation\Response;
use Drupal\views\Plugin\Core\Entity\View;
......@@ -604,7 +605,7 @@ public function initDisplay() {
}
// Initialize the display cache array.
$this->displayHandlers = new DisplayBag($this, drupal_container()->get('plugin.manager.views.display'));
$this->displayHandlers = new DisplayBag($this, Views::pluginManager('display'));
$this->current_display = 'default';
$this->display_handler = $this->displayHandlers->get('default');
......@@ -693,7 +694,7 @@ public function initStyle() {
$this->style_options = $style['options'];
}
$this->style_plugin = drupal_container()->get("plugin.manager.views.style")->createInstance($this->plugin_name);
$this->style_plugin = Views::pluginManager("style")->createInstance($this->plugin_name);
if (empty($this->style_plugin)) {
return FALSE;
......@@ -944,7 +945,7 @@ public function initQuery() {
}
// Create and initialize the query object.
$views_data = drupal_container()->get('views.views_data')->get($this->storage->get('base_table'));
$views_data = Views::viewsData()->get($this->storage->get('base_table'));
$this->storage->set('base_field', !empty($views_data['table']['base']['field']) ? $views_data['table']['base']['field'] : '');
if (!empty($views_data['table']['base']['database'])) {
$this->base_database = $views_data['table']['base']['database'];
......@@ -1937,7 +1938,7 @@ public function addItem($display_id, $type, $table, $field, $options = array(),
) + $options;
// Load the plugin ID if available.
$data = drupal_container()->get('views.views_data')->get($table);
$data = Views::viewsData()->get($table);
if (isset($data[$field][$handler_type]['id'])) {
$fields[$id]['plugin_id'] = $data[$field][$handler_type]['id'];
}
......
<?php
/**
* @file
* Contains \Drupal\views\Views.
*/
namespace Drupal\views;
use Drupal;
/**
* Static service container wrapper for views.
*/
class Views {
/**
* Returns the views data service.
*
* @return \Drupal\views\ViewsDataCache
* Returns a views data cache object.
*/
public static function viewsData() {
return Drupal::service('views.views_data');
}
/**