|
@@ -2,13 +2,13 @@
|
|
|
|
|
|
/*
|
|
/*
|
|
* Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
|
|
* Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* You may obtain a copy of the License at
|
|
- *
|
|
|
|
|
|
+ *
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
@@ -21,6 +21,7 @@ namespace JMS\Serializer\Construction;
|
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
|
use JMS\Serializer\VisitorInterface;
|
|
use JMS\Serializer\VisitorInterface;
|
|
use JMS\Serializer\Metadata\ClassMetadata;
|
|
use JMS\Serializer\Metadata\ClassMetadata;
|
|
|
|
+use JMS\Serializer\DeserializationContext;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Doctrine object constructor for new (or existing) objects during deserialization.
|
|
* Doctrine object constructor for new (or existing) objects during deserialization.
|
|
@@ -45,14 +46,14 @@ class DoctrineObjectConstructor implements ObjectConstructorInterface
|
|
/**
|
|
/**
|
|
* {@inheritdoc}
|
|
* {@inheritdoc}
|
|
*/
|
|
*/
|
|
- public function construct(VisitorInterface $visitor, ClassMetadata $metadata, $data, array $type)
|
|
|
|
|
|
+ public function construct(VisitorInterface $visitor, ClassMetadata $metadata, $data, array $type, DeserializationContext $context)
|
|
{
|
|
{
|
|
// Locate possible ObjectManager
|
|
// Locate possible ObjectManager
|
|
$objectManager = $this->managerRegistry->getManagerForClass($metadata->name);
|
|
$objectManager = $this->managerRegistry->getManagerForClass($metadata->name);
|
|
|
|
|
|
if (!$objectManager) {
|
|
if (!$objectManager) {
|
|
// No ObjectManager found, proceed with normal deserialization
|
|
// No ObjectManager found, proceed with normal deserialization
|
|
- return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type);
|
|
|
|
|
|
+ return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
|
|
}
|
|
}
|
|
|
|
|
|
// Locate possible ClassMetadata
|
|
// Locate possible ClassMetadata
|
|
@@ -60,7 +61,7 @@ class DoctrineObjectConstructor implements ObjectConstructorInterface
|
|
|
|
|
|
if ($classMetadataFactory->isTransient($metadata->name)) {
|
|
if ($classMetadataFactory->isTransient($metadata->name)) {
|
|
// No ClassMetadata found, proceed with normal deserialization
|
|
// No ClassMetadata found, proceed with normal deserialization
|
|
- return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type);
|
|
|
|
|
|
+ return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
|
|
}
|
|
}
|
|
|
|
|
|
// Managed entity, check for proxy load
|
|
// Managed entity, check for proxy load
|
|
@@ -75,7 +76,7 @@ class DoctrineObjectConstructor implements ObjectConstructorInterface
|
|
|
|
|
|
foreach ($classMetadata->getIdentifierFieldNames() as $name) {
|
|
foreach ($classMetadata->getIdentifierFieldNames() as $name) {
|
|
if ( ! array_key_exists($name, $data)) {
|
|
if ( ! array_key_exists($name, $data)) {
|
|
- return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type);
|
|
|
|
|
|
+ return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
|
|
}
|
|
}
|
|
|
|
|
|
$identifierList[$name] = $data[$name];
|
|
$identifierList[$name] = $data[$name];
|