From d243059dce6fc1bc27db112b686ac9647e2ce0ac Mon Sep 17 00:00:00 2001 From: Perreal Guillaume <guillaume.perreal@irstea.fr> Date: Tue, 16 Apr 2019 14:13:03 +0200 Subject: [PATCH] =?UTF-8?q?G=C3=A8re=20correctement=20les=20attributs=20"i?= =?UTF-8?q?nput"=20et=20"output".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notamment s'ils valent "false". --- src/php/Metadata/MetadataFactory.php | 50 +++++++++++++--------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/php/Metadata/MetadataFactory.php b/src/php/Metadata/MetadataFactory.php index 9ee1faa..5c6c372 100644 --- a/src/php/Metadata/MetadataFactory.php +++ b/src/php/Metadata/MetadataFactory.php @@ -253,35 +253,33 @@ final class MetadataFactory implements MetadataFactoryInterface $opDef = new OperationDef($name, $method, $type === OperationType::COLLECTION); - if ($opDef->hasNormalization()) { - $input = $getAttribute('input', $class->getFullName()); - if (is_array($input) && isset($input['class'])) { - $input = $input['class']; - } - $normalization = $this->getOperationSerialization( - $opDef, - PHPClass::get($input), - true, - $getAttribute('normalization_context', [])['groups'] ?? [] - ); - } else { - $normalization = null; + $input = $getAttribute('input', null); + if ($input === null && $opDef->hasNormalization()) { + $input = $class->getFullName(); + } + if (is_array($input) && isset($input['class'])) { + $input = $input['class']; } + $normalization = $input ? $this->getOperationSerialization( + $opDef, + PHPClass::get($input), + true, + $getAttribute('normalization_context', [])['groups'] ?? [] + ) : null; - if ($opDef->hasDenormalization()) { - $output = $getAttribute('output', $class->getFullName()); - if (is_array($output) && isset($output['class'])) { - $output = $output['class']; - } - $denormalization = $this->getOperationSerialization( - $opDef, - PHPClass::get($output), - false, - $getAttribute('denormalization_context', [])['groups'] ?? [] - ); - } else { - $denormalization = null; + $output = $getAttribute('output', null); + if ($input === null && $opDef->hasDenormalization()) { + $output = $class->getFullName(); } + if (is_array($output) && isset($output['class'])) { + $output = $output['class']; + } + $denormalization = $output ? $this->getOperationSerialization( + $opDef, + PHPClass::get($output), + false, + $getAttribute('denormalization_context', [])['groups'] ?? [] + ) : null; return new OperationMetadata( $opDef, -- GitLab