Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -3,7 +3,7 @@
* Form-based in-place editor. Works for any field type.
*/
(function ($, Drupal) {
(function ($, Drupal, _) {
'use strict';
@ -252,4 +252,4 @@
}
});
})(jQuery, Drupal);
})(jQuery, Drupal, _);

View file

@ -3,7 +3,7 @@
* A Backbone Model subclass that enforces validation when calling set().
*/
(function (Backbone) {
(function (Drupal, Backbone) {
'use strict';
@ -57,4 +57,4 @@
});
}(Backbone));
}(Drupal, Backbone));

View file

@ -124,6 +124,11 @@ function quickedit_preprocess_page_title(&$variables) {
* Implements hook_preprocess_HOOK() for field templates.
*/
function quickedit_preprocess_field(&$variables) {
$variables['#cache']['contexts'][] = 'user.permissions';
if (!\Drupal::currentUser()->hasPermission('access in-place editing')) {
return;
}
$element = $variables['element'];
/** @var $entity \Drupal\Core\Entity\EntityInterface */
$entity = $element['#object'];
@ -148,5 +153,10 @@ function quickedit_preprocess_field(&$variables) {
* Implements hook_entity_view_alter().
*/
function quickedit_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
$build['#cache']['contexts'][] = 'user.permissions';
if (!\Drupal::currentUser()->hasPermission('access in-place editing')) {
return;
}
$build['#attributes']['data-quickedit-entity-id'] = $entity->getEntityTypeId() . '/' . $entity->id();
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Access\EditEntityFieldAccessCheck.
*/
namespace Drupal\quickedit\Access;
use Drupal\Core\Access\AccessResult;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface.
*/
namespace Drupal\quickedit\Access;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Ajax\EntitySavedCommand.
*/
namespace Drupal\quickedit\Ajax;
use Drupal\Core\Ajax\BaseCommand;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Ajax\FieldFormCommand.
*/
namespace Drupal\quickedit\Ajax;
use Drupal\Core\Ajax\BaseCommand;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Ajax\FieldFormSavedCommand.
*/
namespace Drupal\quickedit\Ajax;
use Drupal\Core\Ajax\BaseCommand;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Ajax\FieldFormValidationErrorsCommand.
*/
namespace Drupal\quickedit\Ajax;
use Drupal\Core\Ajax\BaseCommand;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Annotation\InPlaceEditor.
*/
namespace Drupal\quickedit\Annotation;
use Drupal\Component\Annotation\Plugin;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\EditorSelector.
*/
namespace Drupal\quickedit;
use Drupal\Component\Plugin\PluginManagerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\EditorSelectorInterface.
*/
namespace Drupal\quickedit;
use Drupal\Core\Field\FieldItemListInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Form\QuickEditFieldForm.
*/
namespace Drupal\quickedit\Form;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\MetadataGenerator.
*/
namespace Drupal\quickedit;
use Drupal\Component\Plugin\PluginManagerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\MetadataGeneratorInterface.
*/
namespace Drupal\quickedit;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Plugin\InPlaceEditor\FormEditor.
*/
namespace Drupal\quickedit\Plugin\InPlaceEditor;
use Drupal\Core\Field\FieldItemListInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Plugin\InPlaceEditor\PlainTextEditor.
*/
namespace Drupal\quickedit\Plugin\InPlaceEditor;
use Drupal\Core\Field\FieldItemListInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Plugin\InPlaceEditorBase.
*/
namespace Drupal\quickedit\Plugin;
use Drupal\Core\Plugin\PluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Plugin\InPlaceEditorInterface.
*/
namespace Drupal\quickedit\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Plugin\InPlaceEditorManager.
*/
namespace Drupal\quickedit\Plugin;
use Drupal\Core\Cache\CacheBackendInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\QuickEditController.
*/
namespace Drupal\quickedit;
use Drupal\Core\Controller\ControllerBase;

View file

@ -1,12 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Tests\EditorSelectionTest.
*/
namespace Drupal\quickedit\Tests;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\quickedit\EditorSelector;
/**
@ -65,7 +61,7 @@ class EditorSelectionTest extends QuickEditTestBase {
);
// Create an entity with values for this text field.
$entity = entity_create('entity_test');
$entity = EntityTest::create();
$entity->{$field_name}->value = 'Hello, world!';
$entity->save();
@ -104,7 +100,7 @@ class EditorSelectionTest extends QuickEditTestBase {
);
// Create an entity with values for this text field.
$entity = entity_create('entity_test');
$entity = EntityTest::create();
$entity->{$field_name}->value = 'Hello, world!';
$entity->{$field_name}->format = 'filtered_html';
$entity->save();
@ -141,7 +137,7 @@ class EditorSelectionTest extends QuickEditTestBase {
);
// Create an entity with values for this text field.
$entity = entity_create('entity_test');
$entity = EntityTest::create();
$entity->{$field_name}->value = 42;
$entity->save();

View file

@ -1,15 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Tests\MetadataGeneratorTest.
*/
namespace Drupal\quickedit\Tests;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\quickedit\EditorSelector;
use Drupal\quickedit\MetadataGenerator;
use Drupal\quickedit_test\MockEditEntityFieldAccessCheck;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests in-place field editing metadata.
@ -92,7 +89,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
);
// Create an entity with values for this text field.
$entity = entity_create('entity_test');
$entity = EntityTest::create();
$entity->{$field_1_name}->value = 'Test';
$entity->{$field_2_name}->value = 42;
$entity->save();
@ -123,8 +120,6 @@ class MetadataGeneratorTest extends QuickEditTestBase {
* Tests a field whose associated in-place editor generates custom metadata.
*/
public function testEditorWithCustomMetadata() {
$this->installSchema('system', 'url_alias');
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
@ -149,7 +144,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
);
// Create a text format.
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
@ -160,7 +155,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
$full_html_format->save();
// Create an entity with values for this rich text field.
$entity = entity_create('entity_test');
$entity = EntityTest::create();
$entity->{$field_name}->value = 'Test';
$entity->{$field_name}->format = 'full_html';
$entity->save();

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Tests\QuickEditAutocompleteTermTest.
*/
namespace Drupal\quickedit\Tests;
use Drupal\Component\Serialization\Json;
@ -12,6 +7,8 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\simpletest\WebTestBase;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\taxonomy\Entity\Term;
/**
* Tests in-place editing of autocomplete tags.
@ -78,7 +75,7 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
'type' => 'article',
));
// Create the vocabulary for the tag field.
$this->vocabulary = entity_create('taxonomy_vocabulary', [
$this->vocabulary = Vocabulary::create([
'name' => 'quickedit testing tags',
'vid' => 'quickedit_testing_tags',
]);
@ -202,14 +199,14 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
protected function createTerm() {
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
$term = entity_create('taxonomy_term', array(
$term = Term::create([
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
// Use the first available text format.
'format' => $format->id(),
'vid' => $this->vocabulary->id(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
));
]);
$term->save();
return $term;
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Tests\QuickEditLoadingTest.
*/
namespace Drupal\quickedit\Tests;
use Drupal\Component\Serialization\Json;
@ -17,6 +12,7 @@ use Drupal\Core\Url;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests loading of in-place editing functionality and lazy loading of its
@ -57,7 +53,7 @@ class QuickEditLoadingTest extends WebTestBase {
parent::setUp();
// Create a text format.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
@ -101,9 +97,10 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertNoRaw('core/modules/quickedit/js/quickedit.js', 'Quick Edit library not loaded.');
$this->assertNoRaw('core/modules/quickedit/js/editors/formEditor.js', "'form' in-place editor not loaded.");
// HTML annotation must always exist (to not break the render cache).
$this->assertRaw('data-quickedit-entity-id="node/1"');
$this->assertRaw('data-quickedit-field-id="node/1/body/en/full"');
// HTML annotation does not exist for users without permission to in-place
// edit.
$this->assertNoRaw('data-quickedit-entity-id="node/1"');
$this->assertNoRaw('data-quickedit-field-id="node/1/body/en/full"');
// Retrieving the metadata should result in an empty 403 response.
$post = array('fields[0]' => 'node/1/body/en/full');
@ -518,6 +515,7 @@ class QuickEditLoadingTest extends WebTestBase {
$this->drupalPlaceBlock('block_content:' . $block->uuid());
// Check that the data- attribute is present.
$this->drupalLogin($this->editorUser);
$this->drupalGet('');
$this->assertRaw('data-quickedit-entity-id="block_content/1"');
}

View file

@ -1,13 +1,10 @@
<?php
/**
* @file
* Contains \Drupal\quickedit\Tests\QuickEditTestBase.
*/
namespace Drupal\quickedit\Tests;
use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\KernelTestBase;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Base class for testing Quick Edit functionality.
@ -70,7 +67,7 @@ abstract class QuickEditTestBase extends KernelTestBase {
*/
protected function createFieldWithStorage($field_name, $type, $cardinality, $label, $field_settings, $widget_type, $widget_settings, $formatter_type, $formatter_settings) {
$field_storage = $field_name . '_field_storage';
$this->fields->$field_storage = entity_create('field_storage_config', array(
$this->fields->$field_storage = FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => $type,
@ -79,14 +76,14 @@ abstract class QuickEditTestBase extends KernelTestBase {
$this->fields->$field_storage->save();
$field = $field_name . '_field';
$this->fields->$field = entity_create('field_config', array(
$this->fields->$field = FieldConfig::create([
'field_storage' => $this->fields->$field_storage,
'bundle' => 'entity_test',
'label' => $label,
'description' => $label,
'weight' => mt_rand(0, 127),
'settings' => $field_settings,
));
]);
$this->fields->$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit_test\MockEditEntityFieldAccessCheck.
*/
namespace Drupal\quickedit_test;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\quickedit_test\Plugin\InPlaceEditor\WysiwygEditor.
*/
namespace Drupal\quickedit_test\Plugin\InPlaceEditor;
use Drupal\Core\Field\FieldItemListInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\quickedit\Unit\Access\EditEntityFieldAccessCheckTest.
*/
namespace Drupal\Tests\quickedit\Unit\Access;
use Drupal\Core\Access\AccessResult;