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:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Encoder\JsonEncoder.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Encoder\DecoderInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Encoder\XmlEncoder.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Encoder\EncoderInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\EntityResolver\ChainEntityResolver.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\EntityResolver;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\EntityResolver\ChainEntityResolverInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\EntityResolver;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\EntityResolver\EntityResolverInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\EntityResolver;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\EntityResolver\TargetIdResolver.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\EntityResolver;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\EntityResolver\UuidReferenceInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\EntityResolver;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\EntityResolver\UuidResolver.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\EntityResolver;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\ComplexDataNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\ConfigEntityNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\ContentEntityNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\EntityNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
|
||||
|
@ -27,12 +22,18 @@ class EntityReferenceFieldItemNormalizer extends ComplexDataNormalizer {
|
|||
public function normalize($field_item, $format = NULL, array $context = []) {
|
||||
$values = parent::normalize($field_item, $format, $context);
|
||||
|
||||
// Add a 'url' value if there is a reference and a canonical URL. Hard code
|
||||
// 'canonical' here as config entities override the default $rel parameter
|
||||
// value to 'edit-form.
|
||||
/** @var \Drupal\Core\Entity\EntityInterface $entity */
|
||||
if (($entity = $field_item->get('entity')->getValue()) && ($url = $entity->url('canonical'))) {
|
||||
$values['url'] = $url;
|
||||
if ($entity = $field_item->get('entity')->getValue()) {
|
||||
$values['target_type'] = $entity->getEntityTypeId();
|
||||
// Add the target entity UUID to the normalized output values.
|
||||
$values['target_uuid'] = $entity->uuid();
|
||||
|
||||
// Add a 'url' value if there is a reference and a canonical URL. Hard
|
||||
// code 'canonical' here as config entities override the default $rel
|
||||
// parameter value to 'edit-form.
|
||||
if ($url = $entity->url('canonical')) {
|
||||
$values['url'] = $url;
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\ListNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\MarkupNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\NormalizerBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\NullNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Normalizer\TypedDataNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Normalizer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\RegisterEntityResolversCompilerPass.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\RegisterSerializationClassesCompilerPass.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\SerializationServiceProvider.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Tests\EntityResolverTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Tests;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\entity_test\Entity\EntityTestMulRev;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Tests that entities references can be resolved.
|
||||
|
@ -36,7 +34,7 @@ class EntityResolverTest extends NormalizerTestBase {
|
|||
\Drupal::service('router.builder')->rebuild();
|
||||
|
||||
// Create the test field storage.
|
||||
entity_create('field_storage_config', array(
|
||||
FieldStorageConfig::create(array(
|
||||
'entity_type' => 'entity_test_mulrev',
|
||||
'field_name' => 'field_test_entity_reference',
|
||||
'type' => 'entity_reference',
|
||||
|
@ -46,11 +44,11 @@ class EntityResolverTest extends NormalizerTestBase {
|
|||
))->save();
|
||||
|
||||
// Create the test field.
|
||||
entity_create('field_config', array(
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test_mulrev',
|
||||
'field_name' => 'field_test_entity_reference',
|
||||
'bundle' => 'entity_test_mulrev',
|
||||
))->save();
|
||||
])->save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Tests\EntitySerializationTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Tests;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
|
@ -116,6 +111,8 @@ class EntitySerializationTest extends NormalizerTestBase {
|
|||
'user_id' => array(
|
||||
array(
|
||||
'target_id' => $this->user->id(),
|
||||
'target_type' => $this->user->getEntityTypeId(),
|
||||
'target_uuid' => $this->user->uuid(),
|
||||
'url' => $this->user->url(),
|
||||
),
|
||||
),
|
||||
|
@ -190,7 +187,7 @@ class EntitySerializationTest extends NormalizerTestBase {
|
|||
'name' => '<name><value>' . $this->values['name'] . '</value></name>',
|
||||
'type' => '<type><value>entity_test_mulrev</value></type>',
|
||||
'created' => '<created><value>' . $this->entity->created->value . '</value></created>',
|
||||
'user_id' => '<user_id><target_id>' . $this->user->id() . '</target_id><url>' . $this->user->url() . '</url></user_id>',
|
||||
'user_id' => '<user_id><target_id>' . $this->user->id() . '</target_id><target_type>' . $this->user->getEntityTypeId() . '</target_type><target_uuid>' . $this->user->uuid() . '</target_uuid><url>' . $this->user->url() . '</url></user_id>',
|
||||
'revision_id' => '<revision_id><value>' . $this->entity->getRevisionId() . '</value></revision_id>',
|
||||
'default_langcode' => '<default_langcode><value>1</value></default_langcode>',
|
||||
'field_test_text' => '<field_test_text><value>' . $this->values['field_test_text']['value'] . '</value><format>' . $this->values['field_test_text']['format'] . '</format></field_test_text>',
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Tests\NormalizerTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Tests;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
@ -25,13 +20,12 @@ abstract class NormalizerTestBase extends KernelTestBase {
|
|||
|
||||
$this->installEntitySchema('entity_test_mulrev');
|
||||
$this->installEntitySchema('user');
|
||||
$this->installSchema('system', array('url_alias', 'router'));
|
||||
$this->installConfig(array('field'));
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
\Drupal::moduleHandler()->invoke('rest', 'install');
|
||||
|
||||
// Auto-create a field for testing.
|
||||
FieldstorageConfig::create(array(
|
||||
FieldStorageConfig::create(array(
|
||||
'entity_type' => 'entity_test_mulrev',
|
||||
'field_name' => 'field_test_text',
|
||||
'type' => 'text',
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization\Tests\SerializationTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization\Tests;
|
||||
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
|
|
|
@ -18,6 +18,6 @@ function entity_serialization_test_entity_field_access_alter(array &$grants, arr
|
|||
// Override default access control from UserAccessControlHandler to allow
|
||||
// access to 'pass' field for the test user.
|
||||
if ($context['field_definition']->getName() == 'pass' && $context['account']->getUsername() == 'serialization_test_user') {
|
||||
$grants[':default'] = AccessResult::allowed()->inheritCacheability($grants[':default'])->cacheUntilEntityChanges($context['items']->getEntity());
|
||||
$grants[':default'] = AccessResult::allowed()->inheritCacheability($grants[':default'])->addCacheableDependency($context['items']->getEntity());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization_test\SerializationTestEncoder.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization_test;
|
||||
|
||||
use Symfony\Component\Serializer\Encoder\EncoderInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\serialization_test\SerializationTestNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\serialization_test;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\Encoder\JsonEncoderTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\Encoder;
|
||||
|
||||
use Drupal\serialization\Encoder\JsonEncoder;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\Encoder\XmlEncoderTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\Encoder;
|
||||
|
||||
use Drupal\serialization\Encoder\XmlEncoder;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\EntityResolver\ChainEntityResolverTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\EntityResolver;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\EntityResolver\UuidResolverTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\EntityResolver;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\Normalizer\ConfigEntityNormalizerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\Normalizer;
|
||||
|
||||
use Drupal\serialization\Normalizer\ConfigEntityNormalizer;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\Normalizer;
|
||||
|
||||
use Drupal\serialization\Normalizer\ContentEntityNormalizer;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\Normalizer\EntityNormalizerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\Normalizer;
|
||||
|
||||
use Drupal\serialization\Normalizer\EntityNormalizer;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\Normalizer\EntityReferenceFieldItemNormalizerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\Normalizer;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
@ -78,6 +73,12 @@ class EntityReferenceFieldItemNormalizerTest extends UnitTestCase {
|
|||
$entity->url('canonical')
|
||||
->willReturn($test_url)
|
||||
->shouldBeCalled();
|
||||
$entity->uuid()
|
||||
->willReturn('080e3add-f9d5-41ac-9821-eea55b7b42fb')
|
||||
->shouldBeCalled();
|
||||
$entity->getEntityTypeId()
|
||||
->willReturn('test_type')
|
||||
->shouldBeCalled();
|
||||
|
||||
$entity_reference = $this->prophesize(TypedDataInterface::class);
|
||||
$entity_reference->getValue()
|
||||
|
@ -92,6 +93,8 @@ class EntityReferenceFieldItemNormalizerTest extends UnitTestCase {
|
|||
|
||||
$expected = [
|
||||
'target_id' => ['value' => 'test'],
|
||||
'target_type' => 'test_type',
|
||||
'target_uuid' => '080e3add-f9d5-41ac-9821-eea55b7b42fb',
|
||||
'url' => $test_url,
|
||||
];
|
||||
$this->assertSame($expected, $normalized);
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\Normalizer\ListNormalizerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\Normalizer;
|
||||
|
||||
use Drupal\Core\TypedData\DataDefinition;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\Normalizer\NullNormalizerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\Normalizer;
|
||||
|
||||
use Drupal\serialization\Normalizer\NullNormalizer;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\serialization\Unit\Normalizer\TypedDataNormalizerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\serialization\Unit\Normalizer;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
|
Reference in a new issue