Skip to content

Commit 83026bd

Browse files
alexndlmsoyuka
authored andcommitted
-refactoring
1 parent b6f7572 commit 83026bd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/State/Provider/DeserializeProvider.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
108108
if ($exception->canUseMessageForUser()) {
109109
$parameters['hint'] = $exception->getMessage();
110110
}
111-
$violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $expectedTypes ?? [])], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, (string) Type::INVALID_TYPE_ERROR));
111+
$violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $expectedTypes)], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, (string) Type::INVALID_TYPE_ERROR));
112112
}
113113
if (0 !== \count($violations)) {
114114
throw new ValidationException($violations);
@@ -125,14 +125,14 @@ private function normalizeExpectedTypes(?array $expectedTypes = null): array
125125
foreach ($expectedTypes ?? [] as $expectedType) {
126126
$normalizedType = $expectedType;
127127

128-
if ((\class_exists($expectedType) || \interface_exists($expectedType))) {
128+
if (class_exists($expectedType) || interface_exists($expectedType)) {
129129
try {
130130
$normalizedType = $this->resourceMetadataCollectionFactory->create($expectedType)->getOperation()->getShortName();
131131
} catch (\Throwable) {
132132
// Do nothing
133133
}
134134

135-
if ($normalizedType === null) {
135+
if (null === $normalizedType) {
136136
$classReflection = new \ReflectionClass($expectedType);
137137
$normalizedType = $classReflection->getShortName();
138138
}
@@ -141,7 +141,6 @@ private function normalizeExpectedTypes(?array $expectedTypes = null): array
141141
$normalizedTypes[] = $normalizedType;
142142
}
143143

144-
145144
return $normalizedTypes;
146145
}
147146
}

src/Symfony/Bundle/Resources/config/symfony/events.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<argument>null</argument>
3838
<argument type="service" id="api_platform.serializer" />
3939
<argument type="service" id="api_platform.serializer.context_builder" />
40+
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
4041
<argument type="service" id="translator" on-invalid="null" />
4142
</service>
4243

0 commit comments

Comments
 (0)