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
vendor/symfony/serializer/Normalizer
|
@ -27,30 +27,40 @@ use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
|
|||
*/
|
||||
abstract class AbstractNormalizer extends SerializerAwareNormalizer implements NormalizerInterface, DenormalizerInterface
|
||||
{
|
||||
const CIRCULAR_REFERENCE_LIMIT = 'circular_reference_limit';
|
||||
const OBJECT_TO_POPULATE = 'object_to_populate';
|
||||
const GROUPS = 'groups';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $circularReferenceLimit = 1;
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
protected $circularReferenceHandler;
|
||||
|
||||
/**
|
||||
* @var ClassMetadataFactoryInterface|null
|
||||
*/
|
||||
protected $classMetadataFactory;
|
||||
|
||||
/**
|
||||
* @var NameConverterInterface|null
|
||||
*/
|
||||
protected $nameConverter;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $callbacks = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $ignoredAttributes = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -185,16 +195,16 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
|
|||
{
|
||||
$objectHash = spl_object_hash($object);
|
||||
|
||||
if (isset($context['circular_reference_limit'][$objectHash])) {
|
||||
if ($context['circular_reference_limit'][$objectHash] >= $this->circularReferenceLimit) {
|
||||
unset($context['circular_reference_limit'][$objectHash]);
|
||||
if (isset($context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash])) {
|
||||
if ($context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash] >= $this->circularReferenceLimit) {
|
||||
unset($context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
++$context['circular_reference_limit'][$objectHash];
|
||||
++$context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash];
|
||||
} else {
|
||||
$context['circular_reference_limit'][$objectHash] = 1;
|
||||
$context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash] = 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -248,18 +258,18 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
|
|||
*/
|
||||
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
|
||||
{
|
||||
if (!$this->classMetadataFactory || !isset($context['groups']) || !is_array($context['groups'])) {
|
||||
if (!$this->classMetadataFactory || !isset($context[static::GROUPS]) || !is_array($context[static::GROUPS])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$allowedAttributes = array();
|
||||
foreach ($this->classMetadataFactory->getMetadataFor($classOrObject)->getAttributesMetadata() as $attributeMetadata) {
|
||||
if (count(array_intersect($attributeMetadata->getGroups(), $context['groups']))) {
|
||||
if (count(array_intersect($attributeMetadata->getGroups(), $context[static::GROUPS]))) {
|
||||
$allowedAttributes[] = $attributesAsString ? $attributeMetadata->getName() : $attributeMetadata;
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($allowedAttributes);
|
||||
return $allowedAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -279,7 +289,9 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
|
|||
* Instantiates an object using constructor parameters when needed.
|
||||
*
|
||||
* This method also allows to denormalize data into an existing object if
|
||||
* it is present in the context with the object_to_populate key.
|
||||
* it is present in the context with the object_to_populate. This object
|
||||
* is removed from the context before being returned to avoid side effects
|
||||
* when recursively normalizing an object graph.
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $class
|
||||
|
@ -294,11 +306,14 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
|
|||
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
|
||||
{
|
||||
if (
|
||||
isset($context['object_to_populate']) &&
|
||||
is_object($context['object_to_populate']) &&
|
||||
$class === get_class($context['object_to_populate'])
|
||||
isset($context[static::OBJECT_TO_POPULATE]) &&
|
||||
is_object($context[static::OBJECT_TO_POPULATE]) &&
|
||||
$context[static::OBJECT_TO_POPULATE] instanceof $class
|
||||
) {
|
||||
return $context['object_to_populate'];
|
||||
$object = $context[static::OBJECT_TO_POPULATE];
|
||||
unset($context[static::OBJECT_TO_POPULATE]);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
$constructor = $reflectionClass->getConstructor();
|
||||
|
|
Reference in a new issue