Issue #2198423 by damiankloip: Store the provider for Views plugins.
parent
40681d9690
commit
b65c8f413d
|
@ -140,12 +140,15 @@ class Comment extends WizardPluginBase {
|
|||
|
||||
// Add permission-based access control.
|
||||
$display_options['access']['type'] = 'perm';
|
||||
$display_options['access']['provider'] = 'user';
|
||||
|
||||
// Add a relationship to nodes.
|
||||
$display_options['relationships']['node']['id'] = 'node';
|
||||
$display_options['relationships']['node']['table'] = 'comment';
|
||||
$display_options['relationships']['node']['field'] = 'node';
|
||||
$display_options['relationships']['node']['required'] = 1;
|
||||
$display_options['relationships']['node']['plugin_id'] = 'standard';
|
||||
$display_options['relationships']['node']['provider'] = 'views';
|
||||
|
||||
// Remove the default fields, since we are customizing them here.
|
||||
unset($display_options['fields']);
|
||||
|
|
|
@ -44,6 +44,7 @@ class File extends WizardPluginBase {
|
|||
|
||||
// Add permission-based access control.
|
||||
$display_options['access']['type'] = 'perm';
|
||||
$display_options['access']['provider'] = 'user';
|
||||
|
||||
// Remove the default fields, since we are customizing them here.
|
||||
unset($display_options['fields']);
|
||||
|
|
|
@ -125,6 +125,7 @@ class Node extends WizardPluginBase {
|
|||
|
||||
// Add permission-based access control.
|
||||
$display_options['access']['type'] = 'perm';
|
||||
$display_options['access']['provider'] = 'user';
|
||||
|
||||
// Remove the default fields, since we are customizing them here.
|
||||
unset($display_options['fields']);
|
||||
|
|
|
@ -88,6 +88,7 @@ class NodeRevision extends WizardPluginBase {
|
|||
|
||||
// Add permission-based access control.
|
||||
$display_options['access']['type'] = 'perm';
|
||||
$display_options['access']['provider'] = 'user';
|
||||
$display_options['access']['perm'] = 'view revisions';
|
||||
|
||||
// Remove the default fields, since we are customizing them here.
|
||||
|
|
|
@ -103,7 +103,7 @@ class CollectRoutesTest extends UnitTestCase {
|
|||
|
||||
$display_manager->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->will($this->returnValue($this->restExport));
|
||||
->will($this->returnValue(array('id' => 'test', 'provider' => 'test')));
|
||||
|
||||
$none = $this->getMockBuilder('\Drupal\views\Plugin\views\access\None')
|
||||
->disableOriginalConstructor()
|
||||
|
|
|
@ -42,6 +42,7 @@ class TaxonomyTerm extends WizardPluginBase {
|
|||
|
||||
// Add permission-based access control.
|
||||
$display_options['access']['type'] = 'perm';
|
||||
$display_options['access']['provider'] = 'user';
|
||||
|
||||
// Remove the default fields, since we are customizing them here.
|
||||
unset($display_options['fields']);
|
||||
|
|
|
@ -64,6 +64,7 @@ class Users extends WizardPluginBase {
|
|||
|
||||
// Add permission-based access control.
|
||||
$display_options['access']['type'] = 'perm';
|
||||
$display_options['access']['provider'] = 'user';
|
||||
$display_options['access']['perm'] = 'access user profiles';
|
||||
|
||||
// Remove the default fields, since we are customizing them here.
|
||||
|
|
|
@ -176,6 +176,7 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
|
|||
}
|
||||
|
||||
$plugin = Views::pluginManager('display')->getDefinition($plugin_id);
|
||||
|
||||
if (empty($plugin)) {
|
||||
$plugin['title'] = t('Broken');
|
||||
}
|
||||
|
@ -208,6 +209,7 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
|
|||
'id' => $id,
|
||||
'display_title' => $title,
|
||||
'position' => count($this->display),
|
||||
'provider' => $plugin['provider'],
|
||||
'display_options' => array(),
|
||||
);
|
||||
|
||||
|
|
|
@ -2234,7 +2234,11 @@ abstract class DisplayPluginBase extends PluginBase {
|
|||
$plugin = Views::pluginManager($plugin_type)->createInstance($form_state['values'][$plugin_type]['type']);
|
||||
if ($plugin) {
|
||||
$plugin->init($this->view, $this, $plugin_options['options']);
|
||||
$plugin_options = array('type' => $form_state['values'][$plugin_type]['type'], 'options' => $plugin->options);
|
||||
$plugin_options = array(
|
||||
'type' => $form_state['values'][$plugin_type]['type'],
|
||||
'options' => $plugin->options,
|
||||
'provider' => $plugin->definition['provider']
|
||||
);
|
||||
$this->setOption($plugin_type, $plugin_options);
|
||||
if ($plugin->usesOptions()) {
|
||||
$form_state['view']->addFormToStack('display', $this->display['id'], $plugin_type . '_options');
|
||||
|
|
|
@ -760,6 +760,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
|
|||
// Add default options array to each plugin type.
|
||||
foreach ($display_options as &$options) {
|
||||
$options['options'] = array();
|
||||
$options['provider'] = 'views';
|
||||
}
|
||||
|
||||
// Add a least one field so the view validates and the user has a preview.
|
||||
|
|
|
@ -72,6 +72,7 @@ class DisplayTest extends PluginTestBase {
|
|||
'id' => 'display_test_1',
|
||||
'display_title' => 'Display test',
|
||||
'position' => 1,
|
||||
'provider' => 'views_test_data',
|
||||
);
|
||||
$this->assertEqual($displays['display_test_1'], $options);
|
||||
|
||||
|
@ -84,6 +85,7 @@ class DisplayTest extends PluginTestBase {
|
|||
'id' => 'display_test_2',
|
||||
'display_title' => 'Display test 2',
|
||||
'position' => 2,
|
||||
'provider' => 'views_test_data',
|
||||
);
|
||||
$this->assertEqual($displays['display_test_2'], $options);
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\views\Tests\Wizard;
|
||||
|
||||
use Drupal\Component\Utility\String;
|
||||
|
||||
/**
|
||||
* Tests creating views with the wizard and viewing them on the listing page.
|
||||
*/
|
||||
|
@ -170,11 +172,15 @@ class BasicTest extends WizardTestBase {
|
|||
// @see \Drupal\views\Tests\Plugin\DisplayUnitTest
|
||||
$view = views_get_view($random_id);
|
||||
$displays = $view->storage->get('display');
|
||||
foreach (array('query', 'exposed_form', 'pager', 'style', 'row') as $type) {
|
||||
foreach ($displays as $display) {
|
||||
$this->assertFalse(empty($display['display_options'][$type]['options']), format_string('Default options found for @plugin.', array('@plugin' => $type)));
|
||||
|
||||
foreach ($displays as $display) {
|
||||
$this->assertIdentical($display['provider'], 'views', 'Expected provider found for display.');
|
||||
|
||||
foreach (array('query', 'exposed_form', 'pager', 'style', 'row') as $type) {
|
||||
$this->assertFalse(empty($display['display_options'][$type]['options']), String::format('Default options found for @plugin.', array('@plugin' => $type)));
|
||||
$this->assertIdentical($display['display_options'][$type]['provider'], 'views', String::format('Expected provider found for @plugin.', array('@plugin' => $type)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -111,6 +111,14 @@ class DisplayTest extends UITestBase {
|
|||
|
||||
$this->assertNoLink('Master*', 0, 'Make sure the master display is not marked as changed.');
|
||||
$this->assertLink('Page*', 0, 'Make sure the added display is marked as changed.');
|
||||
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/path", array('path' => 'test/path'), t('Apply'));
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
|
||||
// Test that the new view display contains the correct provider.
|
||||
$view = Views::getView($view['id']);
|
||||
$displays = $view->storage->get('display');
|
||||
$this->assertIdentical($displays['page_1']['provider'], 'views', 'The expected provider was added to the new display.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
|
||||
use Drupal\Component\Utility\String;
|
||||
use Drupal\views\Plugin\Core\Entity\View;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests some general functionality of editing views, like deleting a view.
|
||||
|
@ -113,4 +115,47 @@ class ViewEditTest extends UITestBase {
|
|||
$this->assertFieldByName('field_langcode_add_to_query', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that plugins selected from the view edit form contain providers.
|
||||
*/
|
||||
public function testPluginProviders() {
|
||||
$plugin_data = array(
|
||||
'access' => array(
|
||||
'value' => 'test_static',
|
||||
'provider' => 'views_test_data',
|
||||
),
|
||||
'cache' => array(
|
||||
'value' => 'time',
|
||||
'provider' => 'views',
|
||||
),
|
||||
'exposed_form' => array(
|
||||
'value' => 'input_required',
|
||||
'provider' => 'views',
|
||||
),
|
||||
'pager' => array(
|
||||
'value' => 'full',
|
||||
'provider' => 'views',
|
||||
),
|
||||
'row' => array(
|
||||
'value' => 'test_row',
|
||||
'provider' => 'views_test_data',
|
||||
),
|
||||
'style' => array(
|
||||
'value' => 'test_style',
|
||||
'provider' => 'views_test_data',
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($plugin_data as $plugin_type => $plugin_options) {
|
||||
$element_name = $plugin_type . '[type]';
|
||||
// Save the plugin form, to change the plugin used.
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/test_view/default/$plugin_type", array($element_name => $plugin_options['value']), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
|
||||
// Check the plugin provider.
|
||||
$view = Views::getView('test_view');
|
||||
$displays = $view->storage->get('display');
|
||||
$this->assertIdentical($displays['default']['display_options'][$plugin_type]['provider'], $plugin_options['provider'], String::format('Expected provider found for @plugin.', array('@plugin' => $plugin_type)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue