From 9422cc38ccd20dcaa8f83e6a2d173ab917136f31 Mon Sep 17 00:00:00 2001 From: Perreal Guillaume <guillaume.perreal@irstea.fr> Date: Tue, 16 Apr 2019 16:30:05 +0200 Subject: [PATCH] Utilisation correcte des attributs "input" et "output". --- src/php/Metadata/MetadataFactory.php | 58 ++++++++++++++++------------ 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/src/php/Metadata/MetadataFactory.php b/src/php/Metadata/MetadataFactory.php index 5c6c372..4e208e0 100644 --- a/src/php/Metadata/MetadataFactory.php +++ b/src/php/Metadata/MetadataFactory.php @@ -253,33 +253,43 @@ final class MetadataFactory implements MetadataFactoryInterface $opDef = new OperationDef($name, $method, $type === OperationType::COLLECTION); - $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; - $output = $getAttribute('output', null); - if ($input === null && $opDef->hasDenormalization()) { - $output = $class->getFullName(); + $normalization = null; + if ($output !== false) { + if (is_array($output) && isset($output['class'])) { + $output = $output['class']; + } + if ($output === null && $opDef->hasNormalization()) { + $output = $class->getFullName(); + } + if ($output) { + $normalization = $this->getOperationSerialization( + $opDef, + PHPClass::get($output), + true, + $getAttribute('normalization_context', [])['groups'] ?? [] + ); + } } - if (is_array($output) && isset($output['class'])) { - $output = $output['class']; + + $input = $getAttribute('input', null); + $denormalization = null; + if ($input !== false) { + if (is_array($input) && isset($input['class'])) { + $input = $input['class']; + } + if ($input === null && $opDef->hasDenormalization()) { + $input = $class->getFullName(); + } + if ($input) { + $denormalization = $this->getOperationSerialization( + $opDef, + PHPClass::get($input), + false, + $getAttribute('denormalization_context', [])['groups'] ?? [] + ); + } } - $denormalization = $output ? $this->getOperationSerialization( - $opDef, - PHPClass::get($output), - false, - $getAttribute('denormalization_context', [])['groups'] ?? [] - ) : null; return new OperationMetadata( $opDef, -- GitLab