Commit e10cd35b authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

N'essaie plus de deviner quand les objets sont embedded.

parent cd36a6ad
......@@ -25,7 +25,6 @@ use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
use ApiPlatform\Core\Metadata\Property\PropertyMetadata as APIPropertyMetadata;
use Irstea\NgModelGeneratorBundle\Models\ClassName;
use Irstea\NgModelGeneratorBundle\Models\PHPClass;
use Symfony\Component\PropertyInfo\Type;
/**
......@@ -139,19 +138,8 @@ class PropertyMetadataFactory
return [false, false];
}
$leafClass = PHPClass::get($leafClassName);
$embedded = $this->mode === self::MODE_READ ? $propertyMeta->isReadableLink() : $propertyMeta->isWritableLink();
if (!\is_bool($embedded)) {
$leafProperties = $this->getAPIMetadata($leafClass);
foreach ($leafProperties as $leafProperty) {
if (!$leafProperty->isIdentifier()) {
$embedded = true;
break;
}
}
}
return [true, (bool) $embedded];
}
......
......@@ -302,18 +302,11 @@ final class SerializationMapper implements TypeFactoryInterface
$leafType = $leafType->getCollectionValueType();
}
if ($propertyMeta->isLink()) {
$leafClassName = $leafType->getClassName();
$type = $this->get($leafClassName);
$iriType = $this->createIRI([PHPClass::get($leafClassName)]);
if (!$propertyMeta->isEmbedded()) {
$type = $iriType;
} elseif (!$this->serialization->isNormalization()) {
$type = Union::create([$type, $iriType]);
}
$leafClassName = $leafType->getClassName();
if ($propertyMeta->isLink() && !$propertyMeta->isEmbedded()) {
$type = $this->createIRI([PHPClass::get($leafClassName)]);
} else {
$type = $this->get($leafType->getClassName() ?: $leafType->getBuiltinType());
$type = $this->get($leafClassName ?: $leafType->getBuiltinType());
}
$number = BuiltinType::get('number');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment