Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542

This commit is contained in:
Pantheon Automation 2015-08-27 12:03:05 -07:00 committed by Greg Anderson
parent 3b2511d96d
commit 81ccda77eb
2155 changed files with 54307 additions and 46870 deletions

View file

@ -9,6 +9,9 @@
/**
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Adds behaviors to the field storage add form.
*/
Drupal.behaviors.fieldUIFieldStorageAddForm = {
attach: function (context) {
@ -56,8 +59,14 @@
};
/**
* Attaches the fieldUIOverview behavior.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches the fieldUIOverview behavior.
*
* @see Drupal.fieldUIOverview.attach
*/
Drupal.behaviors.fieldUIDisplayOverview = {
attach: function (context, settings) {
@ -68,6 +77,8 @@
};
/**
* Namespace for the field UI overview.
*
* @namespace
*/
Drupal.fieldUIOverview = {
@ -76,8 +87,11 @@
* Attaches the fieldUIOverview behavior.
*
* @param {HTMLTableElement} table
* The table element for the overview.
* @param {object} rowsData
* The data of the rows in the table.
* @param {object} rowHandlers
* Handlers to be added to the rows.
*/
attach: function (table, rowsData, rowHandlers) {
var tableDrag = Drupal.tableDrag[table.id];
@ -243,6 +257,7 @@
* Additional data to be populated in the constructed object.
*
* @return {Drupal.fieldUIDisplayOverview.field}
* The field row handler constructed.
*/
Drupal.fieldUIDisplayOverview.field = function (row, data) {
this.row = row;
@ -263,6 +278,7 @@
* Returns the region corresponding to the current form values of the row.
*
* @return {string}
* Either 'hidden' or 'content'.
*/
getRegion: function () {
return (this.$pluginSelect.val() === 'hidden') ? 'hidden' : 'content';

View file

@ -40,10 +40,15 @@ class FieldUI {
* @param array $destinations
* An array of destinations to redirect to.
*
* @return \Drupal\Core\Url
* @return \Drupal\Core\Url|null
* The next destination to redirect to.
*/
public static function getNextDestination(array $destinations) {
// If there are no valid destinations left, return here.
if (empty($destinations)) {
return NULL;
}
$next_destination = array_shift($destinations);
if (is_array($next_destination)) {
$next_destination['options']['query']['destinations'] = $destinations;
@ -59,7 +64,7 @@ class FieldUI {
}
// Redirect to any given path within the same domain.
// @todo Revisit this in https://www.drupal.org/node/2418219.
$next_destination = Url::fromUserInput('/' . $options['path']);
$next_destination = Url::fromUserInput('/' . $options['path'], $options);
}
return $next_destination;
}

View file

@ -567,7 +567,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
if ($form_state->get('plugin_settings_update') === $field_name) {
// Only store settings actually used by the selected plugin.
$default_settings = $this->pluginManager->getDefaultSettings($options['type']);
$options['settings'] = array_intersect_key($values['settings_edit_form']['settings'], $default_settings);
$options['settings'] = isset($values['settings_edit_form']['settings']) ? array_intersect_key($values['settings_edit_form']['settings'], $default_settings) : [];
$options['third_party_settings'] = isset($values['settings_edit_form']['third_party_settings']) ? $values['settings_edit_form']['third_party_settings'] : [];
$form_state->set('plugin_settings_update', NULL);
}

View file

@ -38,8 +38,8 @@ class EntityDisplayModeAddForm extends EntityDisplayModeFormBase {
/**
* {@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);
$form_state->setValueForElement($form['id'], $this->targetEntityTypeId . '.' . $form_state->getValue('id'));
}

View file

@ -150,8 +150,8 @@ class FieldConfigEditForm extends EntityForm {
/**
* {@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);
if (isset($form['default_value'])) {
$item = $form['#entity']->get($this->entity->getName());

View file

@ -146,8 +146,8 @@ class FieldStorageConfigEditForm extends EntityForm {
/**
* {@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);
// Validate field cardinality.
if ($form_state->getValue('cardinality') === 'number' && !$form_state->getValue('cardinality_number')) {

View file

@ -163,6 +163,11 @@ class ManageDisplayTest extends WebTestBase {
$edit = array('fields[field_test][type]' => 'field_no_settings', 'refresh_rows' => 'field_test');
$this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh')));
$this->assertFieldByName('field_test_settings_edit');
// Make sure we can save the third party settings when there are no settings available
$this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit");
$this->drupalPostAjaxForm(NULL, $edit, "field_test_plugin_settings_update");
// Uninstall the module providing third party settings and ensure the button
// is no longer there.
\Drupal::service('module_installer')->uninstall(array('field_third_party_test'));

View file

@ -616,6 +616,20 @@ class ManageFieldsTest extends WebTestBase {
$this->assertUrl($url, array(), 'Stayed on the same page.');
}
/**
* Tests that external URLs in the 'destinations' query parameter are blocked.
*/
public function testExternalDestinations() {
$options = [
'query' => ['destinations' => ['http://example.com']],
];
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body/storage', [], 'Save field settings', $options);
// The external redirect should not fire.
$this->assertUrl('admin/structure/types/manage/article/fields/node.article.body/storage', $options);
$this->assertResponse(200);
$this->assertRaw('Attempt to update field <em class="placeholder">Body</em> failed: <em class="placeholder">The internal path component &#039;http://example.com&#039; is external. You are not allowed to specify an external URL together with internal:/.</em>.');
}
/**
* Tests that deletion removes field storages and fields as expected for a term.
*/

View file

@ -0,0 +1,77 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field_ui\Unit\FieldUiTest.
*/
namespace Drupal\Tests\field_ui\Unit;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\field_ui\FieldUI;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\field_ui\FieldUI
*
* @group field_ui
*/
class FieldUiTest extends UnitTestCase {
/**
* The path validator.
*
* @var \Drupal\Core\Path\PathValidatorInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $pathValidator;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->pathValidator = $this->getMock('Drupal\Core\Path\PathValidatorInterface');
$container = new ContainerBuilder();
$container->set('path.validator', $this->pathValidator);
\Drupal::setContainer($container);
}
/**
* @covers ::getNextDestination
*/
public function testGetNextDestination() {
$destinations = ['admin', 'admin/content'];
$expected_uri = 'base:admin';
$expected_query = [
'destinations' => ['admin/content'],
];
$actual = FieldUI::getNextDestination($destinations);
$this->assertSame($expected_uri, $actual->getUri());
$this->assertSame($expected_query, $actual->getOption('query'));
}
/**
* @covers ::getNextDestination
*/
public function testGetNextDestinationEmpty() {
$destinations = [];
$actual = FieldUI::getNextDestination($destinations);
$this->assertNull($actual);
}
/**
* @covers ::getNextDestination
*/
public function testGetNextDestinationRouteName() {
$destinations = [['route_name' => 'system.admin'], ['route_name' => 'system.admin_content']];
$expected_route_name = 'system.admin';
$expected_query = [
'destinations' => [['route_name' => 'system.admin_content']],
];
$actual = FieldUI::getNextDestination($destinations);
$this->assertSame($expected_route_name, $actual->getRouteName());
$this->assertSame($expected_query, $actual->getOption('query'));
}
}