Issue #1938030 by dawehner: Replace View's usage of drupal_container()->get() with Drupal::service().
parent
7813d65e3f
commit
9ce08a3a2b
|
@ -60,7 +60,7 @@ class ContactFieldsTest extends ViewTestBase {
|
|||
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\ViewExecutable;
|
|||
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 @@ class Field extends FieldPluginBase {
|
|||
$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\ViewExecutable;
|
|||
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 @@ class EntityReverse extends RelationshipPluginBase {
|
|||
$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 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
|
|||
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 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
|
|||
* 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 @@ class DefaultWizardDeriver implements DerivativeInterface {
|
|||
* 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\display\DisplayPluginBase;
|
|||
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 @@ abstract class HandlerBase extends PluginBase {
|
|||
* @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 @@ abstract class HandlerBase extends PluginBase {
|
|||
}
|
||||
}
|
||||
|
||||
$join = drupal_container()->get('plugin.manager.views.join')->createInstance($id, $configuration);
|
||||
$join = Views::pluginManager('join')->createInstance($id, $configuration);
|
||||
|
||||
return $join;
|
||||
}
|
||||
|
@ -690,10 +691,10 @@ abstract class HandlerBase extends PluginBase {
|
|||
// 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\PluginBase;
|
|||
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 @@ abstract class ArgumentPluginBase extends HandlerBase {
|
|||
),
|
||||
);
|
||||
|
||||
$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 @@ abstract class ArgumentPluginBase extends HandlerBase {
|
|||
* 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 @@ abstract class ArgumentPluginBase extends HandlerBase {
|
|||
* 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 @@ abstract class ArgumentPluginBase extends HandlerBase {
|
|||
$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 @@ namespace Drupal\views\Plugin\views\display;
|
|||
|
||||
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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
$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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
|
||||
// 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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
$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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
$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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
$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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
$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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
// 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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
// 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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
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 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
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 @@ abstract class PathPluginBase extends DisplayPluginBase {
|
|||
|
||||
$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 @@ use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
|
|||
* '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\views\Plugin\views\HandlerBase;
|
|||
use Drupal\Component\Annotation\Plugin;
|
||||
use Drupal\Core\Annotation\Translation;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
|
@ -1444,7 +1445,7 @@ class Sql extends QueryPluginBase {
|
|||
$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 @@ class Sql extends QueryPluginBase {
|
|||
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 @@ namespace Drupal\views\Plugin\views\relationship;
|
|||
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 @@ class GroupwiseMax extends RelationshipPluginBase {
|
|||
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 @@ class GroupwiseMax extends RelationshipPluginBase {
|
|||
$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 @@ class GroupwiseMax extends RelationshipPluginBase {
|
|||
*/
|
||||
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 @@ class GroupwiseMax extends RelationshipPluginBase {
|
|||
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\display\DisplayPluginBase;
|
|||
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 @@ abstract class RelationshipPluginBase extends HandlerBase {
|
|||
*/
|
||||
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 @@ abstract class RelationshipPluginBase extends HandlerBase {
|
|||
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 @@ namespace Drupal\views\Plugin\views\row;
|
|||
|
||||
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 @@ abstract class RowPluginBase extends PluginBase {
|
|||
$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 @@ class MenuHierarchy extends SortPluginBase {
|
|||
'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 @@ namespace Drupal\views\Plugin\views\wizard;
|
|||
|
||||
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 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
|
|||
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 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
|
|||
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 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
|
|||
// 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 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
|
|||
}
|
||||
}
|
||||
}
|
||||
$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 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
|
|||
// 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 @@ namespace Drupal\views\Tests\Handler;
|
|||
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 @@ class HandlerAllTest extends HandlerTestBase {
|
|||
*/
|
||||
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 @@ namespace Drupal\views\Tests;
|
|||
/**
|
||||
* Tests basic functions from the Views module.
|
||||
*/
|
||||
use Drupal\views\Views;
|
||||
|
||||
class ModuleTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
|
@ -168,7 +170,7 @@ class ModuleTest extends ViewUnitTestBase {
|
|||
* 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 @@ class FilterTest extends PluginTestBase {
|
|||
*/
|
||||
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 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
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 @@ namespace Drupal\views\Tests\UI;
|
|||
/**
|
||||
* Tests the handling of displays in the UI, adding removing etc.
|
||||
*/
|
||||
use Drupal\views\Views;
|
||||
|
||||
class DisplayTest extends UITestBase {
|
||||
|
||||
/**
|
||||
|
@ -212,7 +214,7 @@ class DisplayTest extends UITestBase {
|
|||
* 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 @@ class ViewExecutable {
|
|||
}
|
||||
|
||||
// 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 @@ class ViewExecutable {
|
|||
$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 @@ class ViewExecutable {
|
|||
}
|
||||
|
||||
// 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 @@ class ViewExecutable {
|
|||
) + $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'];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view executable factory service.
|
||||
*
|
||||
* @return \Drupal\views\ViewExecutableFactory
|
||||
* Returns a views executable factory.
|
||||
*/
|
||||
public static function executableFactory() {
|
||||
return Drupal::service('views.executable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view analyzer.
|
||||
*
|
||||
* @return \Drupal\views\Analyzer
|
||||
* Returns a view analyzer object.
|
||||
*/
|
||||
public static function analyzer() {
|
||||
return Drupal::service('views.analyzer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin manager for a certain views plugin type.
|
||||
*
|
||||
* @param string $type
|
||||
* The plugin type, for example filter.
|
||||
*
|
||||
* @return \Drupal\views\Plugin\ViewsPluginManager
|
||||
*/
|
||||
public static function pluginManager($type) {
|
||||
return Drupal::service('plugin.manager.views.' . $type);
|
||||
}
|
||||
|
||||
}
|
|
@ -101,7 +101,7 @@
|
|||
* Describe data tables (or the equivalent) to Views.
|
||||
*
|
||||
* The data described with this hook is fetched and retrieved by
|
||||
* drupal_container()->get('views.views_data')->get().
|
||||
* \Drupal\views\Views::viewsData()->get().
|
||||
*
|
||||
* @return array
|
||||
* An associative array describing the data structure. Primary key is the
|
||||
|
|
|
@ -13,6 +13,7 @@ use Drupal\Core\Database\Query\AlterableInterface;
|
|||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\Component\Plugin\Exception\PluginException;
|
||||
use Drupal\views\Plugin\Core\Entity\View;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Implements hook_forms().
|
||||
|
@ -569,7 +570,7 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable
|
|||
// contextual links that are intended to be displayed in the requested
|
||||
// location.
|
||||
$plugin_id = $view->displayHandlers->get($display_id)->getPluginId();
|
||||
$plugin = drupal_container()->get('plugin.manager.views.display')->getDefinition($plugin_id);
|
||||
$plugin = Views::pluginManager('display')->getDefinition($plugin_id);
|
||||
// If contextual_links_locations are not set, provide a sane default. (To
|
||||
// avoid displaying any contextual links at all, a display plugin can still
|
||||
// set 'contextual_links_locations' to, e.g., {""}.)
|
||||
|
@ -895,8 +896,8 @@ function views_library_info() {
|
|||
*/
|
||||
function views_get_handler($table, $field, $type, $override = NULL) {
|
||||
// Get the plugin manager for this type.
|
||||
$manager = drupal_container()->get("plugin.manager.views.$type");
|
||||
$data = drupal_container()->get('views.views_data')->get($table);
|
||||
$manager = Views::pluginManager($type);;
|
||||
$data = Views::viewsData()->get($table);
|
||||
|
||||
if (isset($data[$field][$type])) {
|
||||
$definition = $data[$field][$type];
|
||||
|
@ -950,7 +951,7 @@ function views_get_handler($table, $field, $type, $override = NULL) {
|
|||
* A keyed array of in the form of 'base_table' => 'Description'.
|
||||
*/
|
||||
function views_fetch_plugin_names($type, $key = NULL, $base = array()) {
|
||||
$definitions = drupal_container()->get("plugin.manager.views.$type")->getDefinitions();
|
||||
$definitions = Views::pluginManager($type)->getDefinitions();
|
||||
$plugins = array();
|
||||
|
||||
foreach ($definitions as $id => $plugin) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Converts a form element in the add view wizard to be AJAX-enabled.
|
||||
|
@ -442,7 +443,7 @@ function _views_sort_types($a, $b) {
|
|||
function views_fetch_fields($base, $type, $grouping = FALSE, $sub_type = NULL) {
|
||||
static $fields = array();
|
||||
if (empty($fields)) {
|
||||
$data = drupal_container()->get('views.views_data')->get();
|
||||
$data = Views::viewsData()->get();
|
||||
$start = microtime(TRUE);
|
||||
// This constructs this ginormous multi dimensional array to
|
||||
// collect the important data about fields. In the end,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\views_ui\Form\Ajax;
|
||||
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views_ui\ViewUI;
|
||||
use Drupal\views\Analyzer;
|
||||
|
||||
|
@ -38,7 +39,7 @@ class Analyze extends ViewsFormBase {
|
|||
$form['#title'] = t('View analysis');
|
||||
$form['#section'] = 'analyze';
|
||||
|
||||
$analyzer = drupal_container()->get('views.analyzer');
|
||||
$analyzer = Views::analyzer();
|
||||
$messages = $analyzer->getMessages($view->get('executable'));
|
||||
|
||||
$form['analysis'] = array(
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace Drupal\views_ui\Form\Ajax;
|
|||
|
||||
use Drupal\views\ViewStorageInterface;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Provides a form for configuring an item in the Views UI.
|
||||
|
@ -102,7 +103,7 @@ class ConfigItem extends ViewsFormBase {
|
|||
}
|
||||
|
||||
// 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'];
|
||||
$base_fields = views_fetch_fields($base, $form_state['type'], $executable->display_handler->useGroupBy());
|
||||
if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\views_ui\Form\Ajax;
|
||||
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views_ui\ViewUI;
|
||||
|
||||
/**
|
||||
|
@ -83,7 +84,7 @@ class EditDetails extends ViewsFormBase {
|
|||
$view->set($key, $value);
|
||||
}
|
||||
}
|
||||
$bases = drupal_container()->get('views.views_data')->fetchBaseTables();
|
||||
$bases = Views::viewsData()->fetchBaseTables();
|
||||
$form_state['#page_title'] = $view->getHumanName();
|
||||
if (isset($bases[$view->get('base_table')])) {
|
||||
$form_state['#page_title'] .= ' (' . $bases[$view->get('base_table')]['title'] . ')';
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Drupal\views_ui;
|
|||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
|
||||
use Drupal\views\Plugin\views\wizard\WizardException;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Form controller for the Views edit form.
|
||||
|
@ -88,7 +89,7 @@ class ViewAddFormController extends ViewFormControllerBase {
|
|||
|
||||
// Create the "Show" dropdown, which allows the base table of the view to be
|
||||
// selected.
|
||||
$wizard_plugins = drupal_container()->get("plugin.manager.views.wizard")->getDefinitions();
|
||||
$wizard_plugins = Views::pluginManager('wizard')->getDefinitions();
|
||||
$options = array();
|
||||
foreach ($wizard_plugins as $key => $wizard) {
|
||||
$options[$key] = $wizard['title'];
|
||||
|
@ -107,7 +108,7 @@ class ViewAddFormController extends ViewFormControllerBase {
|
|||
|
||||
// Build the rest of the form based on the currently selected wizard plugin.
|
||||
$wizard_key = $show_form['wizard_key']['#default_value'];
|
||||
$wizard_instance = drupal_container()->get("plugin.manager.views.wizard")->createInstance($wizard_key);
|
||||
$wizard_instance = Views::pluginManager('wizard')->createInstance($wizard_key);
|
||||
$form = $wizard_instance->build_form($form, $form_state);
|
||||
|
||||
return $form;
|
||||
|
@ -135,7 +136,7 @@ class ViewAddFormController extends ViewFormControllerBase {
|
|||
*/
|
||||
public function validate(array $form, array &$form_state) {
|
||||
$wizard_type = $form_state['values']['show']['wizard_key'];
|
||||
$wizard_instance = drupal_container()->get('plugin.manager.views.wizard')->createInstance($wizard_type);
|
||||
$wizard_instance = Views::pluginManager('wizard')->createInstance($wizard_type);
|
||||
$form_state['wizard'] = $wizard_instance->getDefinition();
|
||||
$form_state['wizard_instance'] = $wizard_instance;
|
||||
$errors = $form_state['wizard_instance']->validateView($form, $form_state);
|
||||
|
|
Loading…
Reference in New Issue