Commit 9422cc38 authored by Guillaume Perréal's avatar Guillaume Perréal

Utilisation correcte des attributs "input" et "output".

parent d243059d
...@@ -253,33 +253,43 @@ final class MetadataFactory implements MetadataFactoryInterface ...@@ -253,33 +253,43 @@ final class MetadataFactory implements MetadataFactoryInterface
$opDef = new OperationDef($name, $method, $type === OperationType::COLLECTION); $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); $output = $getAttribute('output', null);
if ($input === null && $opDef->hasDenormalization()) { $normalization = null;
$output = $class->getFullName(); 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( return new OperationMetadata(
$opDef, $opDef,
......
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