updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
@@ -4,8 +4,9 @@ namespace Drupal\serialization\Encoder;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
use Symfony\Component\Serializer\Encoder\DecoderInterface;
use Symfony\Component\Serializer\Encoder\SerializerAwareEncoder;
use Symfony\Component\Serializer\Encoder\XmlEncoder as BaseXmlEncoder;
use Symfony\Component\Serializer\SerializerAwareInterface;
use Symfony\Component\Serializer\SerializerAwareTrait;
/**
* Adds XML support for serializer.
@@ -17,7 +18,9 @@ use Symfony\Component\Serializer\Encoder\XmlEncoder as BaseXmlEncoder;
* This encoder should not be used directly. Rather, use the `serializer`
* service.
*/
class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, DecoderInterface {
class XmlEncoder implements SerializerAwareInterface, EncoderInterface, DecoderInterface {
use SerializerAwareTrait;
/**
* The formats that this Encoder supports.
@@ -2,7 +2,7 @@
namespace Drupal\serialization\EntityResolver;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
@@ -11,20 +11,20 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class UuidResolver implements EntityResolverInterface {
/**
* The entity manager.
* The entity repository.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected $entityManager;
protected $entityRepository;
/**
* Constructs a UuidResolver object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
* The entity repository.
*/
public function __construct(EntityManagerInterface $entity_manager) {
$this->entityManager = $entity_manager;
public function __construct(EntityRepositoryInterface $entity_repository) {
$this->entityRepository = $entity_repository;
}
/**
@@ -35,7 +35,7 @@ class UuidResolver implements EntityResolverInterface {
// deserialized. If it can return a UUID from that data, and if there's an
// entity with that UUID, then return its ID.
if (($normalizer instanceof UuidReferenceInterface) && ($uuid = $normalizer->getUuid($data))) {
if ($entity = $this->entityManager->loadEntityByUuid($entity_type, $uuid)) {
if ($entity = $this->entityRepository->loadEntityByUuid($entity_type, $uuid)) {
return $entity->id();
}
}
@@ -34,7 +34,10 @@ class ComplexDataNormalizer extends NormalizerBase {
// Other normalizers that extend this class may only provide $object that
// implements \Traversable.
if ($object instanceof ComplexDataInterface) {
$object = TypedDataInternalPropertiesHelper::getNonInternalProperties($object);
// If there are no properties to normalize, just normalize the value.
$object = !empty($object->getProperties(TRUE))
? TypedDataInternalPropertiesHelper::getNonInternalProperties($object)
: $object->getValue();
}
/** @var \Drupal\Core\TypedData\TypedDataInterface $property */
foreach ($object as $name => $property) {
@@ -40,7 +40,7 @@ class EntityNormalizer extends ComplexDataNormalizer implements DenormalizerInte
// The bundle property will be required to denormalize a bundleable
// fieldable entity.
if ($entity_type_definition->isSubclassOf(FieldableEntityInterface::class)) {
if ($entity_type_definition->entityClassImplements(FieldableEntityInterface::class)) {
// Extract bundle data to pass into entity creation if the entity type uses
// bundles.
if ($entity_type_definition->hasKey('bundle')) {
@@ -12,6 +12,8 @@ use Symfony\Component\Serializer\Exception\UnexpectedValueException;
*/
class EntityReferenceFieldItemNormalizer extends FieldItemNormalizer {
use EntityReferenceFieldItemNormalizerTrait;
/**
* The interface or class that this Normalizer supports.
*
@@ -42,6 +44,8 @@ class EntityReferenceFieldItemNormalizer extends FieldItemNormalizer {
public function normalize($field_item, $format = NULL, array $context = []) {
$values = parent::normalize($field_item, $format, $context);
$this->normalizeRootReferenceValue($values, $field_item);
/** @var \Drupal\Core\Entity\EntityInterface $entity */
if ($entity = $field_item->get('entity')->getValue()) {
$values['target_type'] = $entity->getEntityTypeId();
@@ -55,6 +59,7 @@ class EntityReferenceFieldItemNormalizer extends FieldItemNormalizer {
$values['url'] = $url;
}
}
return $values;
}
@@ -73,7 +78,7 @@ class EntityReferenceFieldItemNormalizer extends FieldItemNormalizer {
throw new UnexpectedValueException(sprintf('The field "%s" property "target_type" must be set to "%s" or omitted.', $field_item->getFieldDefinition()->getName(), $target_type));
}
if ($entity = $this->entityRepository->loadEntityByUuid($target_type, $data['target_uuid'])) {
return ['target_id' => $entity->id()];
return ['target_id' => $entity->id()] + array_intersect_key($data, $field_item->getProperties());
}
else {
// Unable to load entity by uuid.
@@ -0,0 +1,30 @@
<?php
namespace Drupal\serialization\Normalizer;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
/**
* Converts empty reference values for entity reference items.
*/
trait EntityReferenceFieldItemNormalizerTrait {
protected function normalizeRootReferenceValue(&$values, EntityReferenceItem $field_item) {
// @todo Generalize for all tree-structured entity types.
if ($this->fieldItemReferencesTaxonomyTerm($field_item) && empty($values['target_id'])) {
$values['target_id'] = NULL;
}
}
/**
* Determines if a field item references a taxonomy term.
*
* @param \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $field_item
*
* @return bool
*/
protected function fieldItemReferencesTaxonomyTerm(EntityReferenceItem $field_item) {
return $field_item->getFieldDefinition()->getSetting('target_type') === 'taxonomy_term';
}
}
@@ -3,12 +3,15 @@
namespace Drupal\serialization\Normalizer;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer;
use Symfony\Component\Serializer\SerializerAwareInterface;
use Symfony\Component\Serializer\SerializerAwareTrait;
/**
* Base class for Normalizers.
*/
abstract class NormalizerBase extends SerializerAwareNormalizer implements CacheableNormalizerInterface {
abstract class NormalizerBase implements SerializerAwareInterface, CacheableNormalizerInterface {
use SerializerAwareTrait;
/**
* The interface or class that this Normalizer supports.
@@ -23,6 +23,9 @@ class RegisterSerializationClassesCompilerPass implements CompilerPassInterface
// Retrieve registered Normalizers and Encoders from the container.
foreach ($container->findTaggedServiceIds('normalizer') as $id => $attributes) {
// The 'serializer' service is the public API: mark normalizers private.
$container->getDefinition($id)->setPublic(FALSE);
// If there is a BC key present, pass this to determine if the normalizer
// should be skipped.
if (isset($attributes[0]['bc']) && $this->normalizerBcSettingIsEnabled($attributes[0]['bc'], $attributes[0]['bc_config_name'])) {
@@ -33,6 +36,9 @@ class RegisterSerializationClassesCompilerPass implements CompilerPassInterface
$normalizers[$priority][] = new Reference($id);
}
foreach ($container->findTaggedServiceIds('encoder') as $id => $attributes) {
// The 'serializer' service is the public API: mark encoders private.
$container->getDefinition($id)->setPublic(FALSE);
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
$encoders[$priority][] = new Reference($id);
}