Commit 79eaae2b authored by catch's avatar catch
Browse files

Issue #1783196 by dawehner, tim.plunkett, damiankloip: Get the views plugin...

Issue #1783196 by dawehner, tim.plunkett, damiankloip: Get the views plugin manager from the DIC when possible.
parent 2b1d1d61
......@@ -1128,7 +1128,7 @@ public function optionsSummary(&$categories, &$options) {
$pager_plugin = $this->getPlugin('pager');
if (!$pager_plugin) {
// default to the no pager plugin.
$pager_plugin = views_get_plugin('pager', 'none');
$pager_plugin = drupal_container()->get('plugin.manager.views.pager')->createInstance('none');
}
$pager_str = $pager_plugin->summaryTitle();
......@@ -1194,7 +1194,7 @@ public function optionsSummary(&$categories, &$options) {
$access_plugin = $this->getPlugin('access');
if (!$access_plugin) {
// default to the no access control plugin.
$access_plugin = views_get_plugin('access', 'none');
$access_plugin = drupal_container()->get('plugin.manager.views.access')->createInstance('none');
}
$access_str = $access_plugin->summaryTitle();
......@@ -1214,7 +1214,7 @@ public function optionsSummary(&$categories, &$options) {
$cache_plugin = $this->getPlugin('cache');
if (!$cache_plugin) {
// default to the no cache control plugin.
$cache_plugin = views_get_plugin('cache', 'none');
$cache_plugin = drupal_container()->get('plugin.manager.views.cache')->createInstance('none');
}
$cache_str = $cache_plugin->summaryTitle();
......@@ -1259,7 +1259,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 = views_get_plugin('exposed_form', 'basic');
$exposed_form_plugin = drupal_container()->get('plugin.manager.views.exposed_form')->createInstance('basic');
}
$exposed_form_str = $exposed_form_plugin->summaryTitle();
......@@ -2124,7 +2124,7 @@ public function submitOptionsForm(&$form, &$form_state) {
case 'access':
$access = $this->getOption('access');
if ($access['type'] != $form_state['values']['access']['type']) {
$plugin = views_get_plugin('access', $form_state['values']['access']['type']);
$plugin = drupal_container()->get('plugin.manager.views.access')->createInstance($form_state['values']['access']['type']);
if ($plugin) {
$access = array('type' => $form_state['values']['access']['type']);
$this->setOption('access', $access);
......@@ -2147,7 +2147,7 @@ public function submitOptionsForm(&$form, &$form_state) {
case 'cache':
$cache = $this->getOption('cache');
if ($cache['type'] != $form_state['values']['cache']['type']) {
$plugin = views_get_plugin('cache', $form_state['values']['cache']['type']);
$plugin = drupal_container()->get('plugin.manager.views.cache')->createInstance($form_state['values']['cache']['type']);
if ($plugin) {
$cache = array('type' => $form_state['values']['cache']['type']);
$this->setOption('cache', $cache);
......@@ -2206,7 +2206,7 @@ public function submitOptionsForm(&$form, &$form_state) {
// the plugin.
$row = $this->getOption('row');
if ($row['type'] != $form_state['values'][$section]) {
$plugin = views_get_plugin('row', $form_state['values'][$section]);
$plugin = drupal_container()->get('plugin.manager.views.row')->createInstance($form_state['values'][$section]);
if ($plugin) {
$row = array('type' => $form_state['values'][$section]);
$this->setOption($section, $row);
......@@ -2223,7 +2223,7 @@ public function submitOptionsForm(&$form, &$form_state) {
// the plugin.
$style = $this->getOption('style');
if ($style['type'] != $form_state['values'][$section]) {
$plugin = views_get_plugin('style', $form_state['values'][$section]);
$plugin = drupal_container()->get('plugin.manager.views.style')->createInstance($form_state['values'][$section]);
if ($plugin) {
$row = array('type' => $form_state['values'][$section]);
$this->setOption($section, $row);
......@@ -2258,7 +2258,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 = views_get_plugin('exposed_form', $form_state['values']['exposed_form']['type']);
$plugin = drupal_container()->get('plugin.manager.views.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);
......@@ -2281,7 +2281,7 @@ public function submitOptionsForm(&$form, &$form_state) {
case 'pager':
$pager = $this->getOption('pager');
if ($pager['type'] != $form_state['values']['pager']['type']) {
$plugin = views_get_plugin('pager', $form_state['values']['pager']['type']);
$plugin = drupal_container()->get('plugin.manager.views.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.
......
......@@ -1310,21 +1310,6 @@ function views_fetch_plugin_names($type, $key = NULL, $base = array()) {
return array();
}
/**
* Get an instance of a plugin.
*
* @param string $type
* The plugin type, e.g., 'access' or 'display'.
* @param string $plugin_id
* The name of the plugin, e.g., 'standard'.
*
* @return Drupal\views\Plugin\view\PluginBase
* The created plugin instance.
*/
function views_get_plugin($type, $plugin_id) {
return drupal_container()->get("plugin.manager.views.$type")->createInstance($plugin_id);
}
/**
* Gets all the views plugin definitions.
*
......
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