Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
@ -196,7 +196,7 @@ class ViewsUIController extends ControllerBase {
|
|||
* Returns the form to edit a view.
|
||||
*
|
||||
* @param \Drupal\views_ui\ViewUI $view
|
||||
* The view being deleted.
|
||||
* The view to be edited.
|
||||
* @param string|null $display_id
|
||||
* (optional) The display ID being edited. Defaults to NULL, which will load
|
||||
* the first available display.
|
||||
|
|
|
@ -12,6 +12,8 @@ use Drupal\Core\Ajax\OpenModalDialogCommand;
|
|||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\Core\Render\RenderContext;
|
||||
use Drupal\views_ui\ViewUI;
|
||||
use Drupal\views\ViewEntityInterface;
|
||||
use Drupal\views\Ajax;
|
||||
|
@ -205,8 +207,21 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
|
|||
}
|
||||
$form_state->disableCache();
|
||||
|
||||
$form = \Drupal::formBuilder()->buildForm($form_class, $form_state);
|
||||
// Builds the form in a render context in order to ensure that cacheable
|
||||
// metadata is bubbled up.
|
||||
$render_context = new RenderContext();
|
||||
$callable = function () use ($form_class, &$form_state) {
|
||||
return \Drupal::formBuilder()->buildForm($form_class, $form_state);
|
||||
};
|
||||
$form = $renderer->executeInRenderContext($render_context, $callable);
|
||||
|
||||
if (!$render_context->isEmpty()) {
|
||||
BubbleableMetadata::createFromRenderArray($form)
|
||||
->merge($render_context->pop())
|
||||
->applyTo($form);
|
||||
}
|
||||
$output = $renderer->renderRoot($form);
|
||||
|
||||
drupal_process_attached($form);
|
||||
|
||||
// These forms have the title built in, so set the title here:
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains Drupal\views_ui\ProxyClass\ParamConverter\ViewUIConverter.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file was generated via php core/scripts/generate-proxy-class.php 'Drupal\views_ui\ParamConverter\ViewUIConverter' "core/modules/views_ui/src".
|
||||
*/
|
||||
|
||||
namespace Drupal\views_ui\ProxyClass\ParamConverter {
|
||||
|
||||
/**
|
||||
* Provides a proxy class for \Drupal\views_ui\ParamConverter\ViewUIConverter.
|
||||
*
|
||||
* @see \Drupal\Component\ProxyBuilder
|
||||
*/
|
||||
class ViewUIConverter implements \Drupal\Core\ParamConverter\ParamConverterInterface
|
||||
{
|
||||
|
||||
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
|
||||
/**
|
||||
* The id of the original proxied service.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $drupalProxyOriginalServiceId;
|
||||
|
||||
/**
|
||||
* The real proxied service, after it was lazy loaded.
|
||||
*
|
||||
* @var \Drupal\views_ui\ParamConverter\ViewUIConverter
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
/**
|
||||
* The service container.
|
||||
*
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructs a ProxyClass Drupal proxy object.
|
||||
*
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
|
||||
* The container.
|
||||
* @param string $drupal_proxy_original_service_id
|
||||
* The service ID of the original service.
|
||||
*/
|
||||
public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $drupal_proxy_original_service_id)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->drupalProxyOriginalServiceId = $drupal_proxy_original_service_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy loads the real service from the container.
|
||||
*
|
||||
* @return object
|
||||
* Returns the constructed real service.
|
||||
*/
|
||||
protected function lazyLoadItself()
|
||||
{
|
||||
if (!isset($this->service)) {
|
||||
$this->service = $this->container->get($this->drupalProxyOriginalServiceId);
|
||||
}
|
||||
|
||||
return $this->service;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function convert($value, $definition, $name, array $defaults)
|
||||
{
|
||||
return $this->lazyLoadItself()->convert($value, $definition, $name, $defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function applies($definition, $name, \Symfony\Component\Routing\Route $route)
|
||||
{
|
||||
return $this->lazyLoadItself()->applies($definition, $name, $route);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
use Drupal\Core\Menu\MenuTreeParameters;
|
||||
use Drupal\menu_link_content\Entity\MenuLinkContent;
|
||||
|
||||
/**
|
||||
* Tests the UI of generic display path plugin.
|
||||
|
@ -149,4 +151,71 @@ class DisplayPathTest extends UITestBase {
|
|||
$this->assertCacheContext('user.permissions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the regression in https://www.drupal.org/node/2532490.
|
||||
*/
|
||||
public function testDefaultMenuTabRegression() {
|
||||
$this->container->get('module_installer')->install(['menu_ui', 'menu_link_content', 'toolbar', 'system']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer blocks',
|
||||
'bypass node access',
|
||||
'access user profiles',
|
||||
'view all revisions',
|
||||
'administer permissions',
|
||||
'administer menu',
|
||||
'link to any page',
|
||||
'access toolbar',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$edit = [
|
||||
'title[0][value]' => 'Menu title',
|
||||
'link[0][uri]' => '/admin/foo',
|
||||
'menu_parent' => 'admin:system.admin'
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/menu/manage/admin/add', $edit, t('Save'));
|
||||
|
||||
$menu_items = \Drupal::entityManager()->getStorage('menu_link_content')->getQuery()
|
||||
->sort('id', 'DESC')
|
||||
->pager(1)
|
||||
->execute();
|
||||
$menu_item = end($menu_items);
|
||||
/** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_link_content */
|
||||
$menu_link_content = MenuLinkContent::load($menu_item);
|
||||
|
||||
$edit = [];
|
||||
$edit['label'] = $this->randomMachineName(16);
|
||||
$view_id = $edit['id'] = strtolower($this->randomMachineName(16));
|
||||
$edit['description'] = $this->randomMachineName(16);
|
||||
$edit['page[create]'] = TRUE;
|
||||
$edit['page[path]'] = 'admin/foo';
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/add', $edit, t('Save and edit'));
|
||||
|
||||
$parameters = new MenuTreeParameters();
|
||||
$parameters->addCondition('id', $menu_link_content->getPluginId());
|
||||
$result = \Drupal::menuTree()->load('admin', $parameters);
|
||||
$plugin_definition = end($result)->link->getPluginDefinition();
|
||||
$this->assertEqual('view.' . $view_id . '.page_1', $plugin_definition['route_name']);
|
||||
|
||||
$this->clickLink(t('No menu'));
|
||||
|
||||
$this->drupalPostForm(NULL, [
|
||||
'menu[type]' => 'default tab',
|
||||
'menu[title]' => 'Menu title',
|
||||
], t('Apply'));
|
||||
|
||||
$this->assertText('Default tab options');
|
||||
|
||||
$this->drupalPostForm(NULL, [
|
||||
'tab_options[type]' => 'normal',
|
||||
'tab_options[title]' => 'Parent title',
|
||||
], t('Apply'));
|
||||
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
// Assert that saving the view will not cause an exception.
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
|
||||
// Confirm that the view block is available in the block administration UI.
|
||||
$this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default'));
|
||||
$this->clickLinkPartialName('Place block');
|
||||
$this->assertText($view['label']);
|
||||
|
||||
// Place the block.
|
||||
|
@ -109,6 +110,7 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
|
||||
// Confirm that the block is available in the block administration UI.
|
||||
$this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default'));
|
||||
$this->clickLinkPartialName('Place block');
|
||||
$this->assertText($view['label']);
|
||||
|
||||
// Put the block into the first sidebar region, and make sure it will not
|
||||
|
|
|
@ -74,4 +74,23 @@ abstract class UITestBase extends ViewTestBase {
|
|||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function drupalGet($path, array $options = array(), array $headers = array()) {
|
||||
$url = $this->buildUrl($path, $options);
|
||||
|
||||
// Ensure that each nojs page is accessible via ajax as well.
|
||||
if (strpos($url, 'nojs') !== FALSE) {
|
||||
$url = str_replace('nojs', 'ajax', $url);
|
||||
$result = $this->drupalGet($url, $options, $headers);
|
||||
$this->assertResponse(200);
|
||||
$this->assertHeader('Content-Type', 'application/json');
|
||||
$this->assertTrue(json_decode($result), 'Ensure that the AJAX request returned valid content.');
|
||||
}
|
||||
|
||||
return parent::drupalGet($path, $options, $headers);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ class ViewAddForm extends ViewFormBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate(array $form, FormStateInterface $form_state) {
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$wizard_type = $form_state->getValue(array('show', 'wizard_key'));
|
||||
$wizard_instance = $this->wizardManager->createInstance($wizard_type);
|
||||
$form_state->set('wizard', $wizard_instance->getPluginDefinition());
|
||||
|
|
|
@ -58,7 +58,6 @@ class ViewDuplicateForm extends ViewFormBase {
|
|||
$actions['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Duplicate'),
|
||||
'#submit' => array('::submitForm'),
|
||||
);
|
||||
return $actions;
|
||||
}
|
||||
|
|
|
@ -122,12 +122,6 @@ class ViewEditForm extends ViewFormBase {
|
|||
$form['#attached']['library'][] = 'views_ui/views_ui.admin';
|
||||
$form['#attached']['library'][] = 'views_ui/admin.styling';
|
||||
|
||||
$form['#attached']['drupalSettings']['views']['ajax'] = [
|
||||
'id' => '.views-ajax-body',
|
||||
'title' => '.views-ajax-title',
|
||||
'popup' => '.views-ajax-popup',
|
||||
];
|
||||
|
||||
$form += array(
|
||||
'#prefix' => '',
|
||||
'#suffix' => '',
|
||||
|
@ -220,23 +214,6 @@ class ViewEditForm extends ViewFormBase {
|
|||
'#type' => 'container',
|
||||
'tab_content' => $tab_content,
|
||||
);
|
||||
|
||||
// The content of the popup dialog.
|
||||
$form['ajax-area'] = array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array('views-ajax-popup'),
|
||||
),
|
||||
);
|
||||
$form['ajax-area']['ajax-title'] = array(
|
||||
'#markup' => '<div class="views-ajax-title"></div>',
|
||||
);
|
||||
$form['ajax-area']['ajax-body'] = array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array('views-ajax-body'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $form;
|
||||
|
@ -264,8 +241,8 @@ class ViewEditForm extends ViewFormBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate(array $form, FormStateInterface $form_state) {
|
||||
parent::validate($form, $form_state);
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
parent::validateForm($form, $form_state);
|
||||
|
||||
$view = $this->entity;
|
||||
if ($view->isLocked()) {
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Drupal\views_ui;
|
|||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\Timer;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Config\Entity\ThirdPartySettingsInterface;
|
||||
use Drupal\Core\EventSubscriber\AjaxResponseSubscriber;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Url;
|
||||
|
@ -18,7 +17,6 @@ use Drupal\views\Views;
|
|||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\TypedData\TypedDataInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\views\Plugin\views\query\Sql;
|
||||
use Drupal\views\Entity\View;
|
||||
|
@ -1336,4 +1334,40 @@ class ViewUI implements ViewEntityInterface {
|
|||
return $this->storage->hasTrustedData();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addCacheableDependency($other_object) {
|
||||
$this->storage->addCacheableDependency($other_object);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addCacheContexts(array $cache_contexts) {
|
||||
return $this->storage->addCacheContexts($cache_contexts);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function mergeCacheMaxAge($max_age) {
|
||||
return $this->storage->mergeCacheMaxAge($max_age);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheTagsToInvalidate() {
|
||||
return $this->storage->getCacheTagsToInvalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addCacheTags(array $cache_tags) {
|
||||
return $this->storage->addCacheTags($cache_tags);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue