chore: commit vendor for offline build
Deploy Backend / deploy (push) Failing after 1m13s

This commit is contained in:
parsa aghaei committed 2026-06-28 16:47:17 +03:30
1 parent f7c532a648
commit 640bd67556
5801 files changed
+484532 -55857

No files matched your search

@@ -25,6 +25,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NearMissValueResolverException;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Serializer\Exception\InvalidArgumentException as SerializerInvalidArgumentException;
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
use Symfony\Component\Serializer\Exception\PartialDenormalizationException;
use Symfony\Component\Serializer\Exception\UnexpectedPropertyException;
@@ -46,11 +47,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscriberInterface
{
/**
* @see \Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT
* @see DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS
*/
private const CONTEXT_DENORMALIZE = [
'disable_type_enforcement' => true,
'collect_denormalization_errors' => true,
];
@@ -65,6 +64,7 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
private readonly SerializerInterface&DenormalizerInterface $serializer,
private readonly ?ValidatorInterface $validator = null,
private readonly ?TranslatorInterface $translator = null,
private string $translationDomain = 'validators',
) {
}
@@ -80,16 +80,16 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
}
if (!$attribute instanceof MapUploadedFile && $argument->isVariadic()) {
throw new \LogicException(sprintf('Mapping variadic argument "$%s" is not supported.', $argument->getName()));
throw new \LogicException(\sprintf('Mapping variadic argument "$%s" is not supported.', $argument->getName()));
}
if ($attribute instanceof MapRequestPayload) {
if ('array' === $argument->getType()) {
if (!$attribute->type) {
throw new NearMissValueResolverException(sprintf('Please set the $type argument of the #[%s] attribute to the type of the objects in the expected array.', MapRequestPayload::class));
throw new NearMissValueResolverException(\sprintf('Please set the $type argument of the #[%s] attribute to the type of the objects in the expected array.', MapRequestPayload::class));
}
} elseif ($attribute->type) {
throw new NearMissValueResolverException(sprintf('Please set its type to "array" when using argument $type of #[%s].', MapRequestPayload::class));
throw new NearMissValueResolverException(\sprintf('Please set its type to "array" when using argument $type of #[%s].', MapRequestPayload::class));
}
}
@@ -118,7 +118,7 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
$request = $event->getRequest();
if (!$argument->metadata->getType()) {
throw new \LogicException(sprintf('Could not resolve the "$%s" controller argument: argument should be typed.', $argument->metadata->getName()));
throw new \LogicException(\sprintf('Could not resolve the "$%s" controller argument: argument should be typed.', $argument->metadata->getName()));
}
if ($this->validator) {
@@ -126,7 +126,7 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
try {
$payload = $payloadMapper($request, $argument->metadata, $argument);
} catch (PartialDenormalizationException $e) {
$trans = $this->translator ? $this->translator->trans(...) : fn ($m, $p) => strtr($m, $p);
$trans = $this->translator ? $this->translator->trans(...) : static fn ($m, $p) => strtr($m, $p);
foreach ($e->getErrors() as $error) {
$parameters = [];
$template = 'This value was of an unexpected type.';
@@ -137,10 +137,13 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
if ($error->canUseMessageForUser()) {
$parameters['hint'] = $error->getMessage();
}
$message = $trans($template, $parameters, 'validators');
$message = $trans($template, $parameters, $this->translationDomain);
$violations->add(new ConstraintViolation($message, $template, $parameters, null, $error->getPath(), null));
}
$payload = $e->getData();
} catch (SerializerInvalidArgumentException $e) {
$violations->add(new ConstraintViolation($e->getMessage(), $e->getMessage(), [], null, '', null));
$payload = null;
}
if (null !== $payload && !\count($violations)) {
@@ -148,7 +151,11 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
if (\is_array($payload) && !empty($constraints) && !$constraints instanceof Assert\All) {
$constraints = new Assert\All($constraints);
}
$violations->addAll($this->validator->validate($payload, $constraints, $argument->validationGroups ?? null));
if ($argument instanceof MapUploadedFile) {
$violations->addAll($this->validator->startContext()->atPath($argument->metadata->getName())->validate($payload, $constraints, $argument->validationGroups ?? null)->getViolations());
} else {
$violations->addAll($this->validator->validate($payload, $constraints, $argument->validationGroups ?? null));
}
}
if (\count($violations)) {
@@ -159,9 +166,16 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
$payload = $payloadMapper($request, $argument->metadata, $argument);
} catch (PartialDenormalizationException $e) {
throw HttpException::fromStatusCode($validationFailedCode, implode("\n", array_map(static fn ($e) => $e->getMessage(), $e->getErrors())), $e);
} catch (SerializerInvalidArgumentException $e) {
throw HttpException::fromStatusCode($validationFailedCode, $e->getMessage(), $e);
}
}
if ($argument->metadata->isVariadic()) {
array_splice($arguments, $i, 1, $payload ?? []);
continue;
}
if (null === $payload) {
$payload = match (true) {
$argument->metadata->hasDefaultValue() => $argument->metadata->getDefaultValue(),
@@ -185,21 +199,25 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
private function mapQueryString(Request $request, ArgumentMetadata $argument, MapQueryString $attribute): ?object
{
if (!$data = $request->query->all()) {
if (!($data = $request->query->all($attribute->key)) && ($argument->isNullable() || $argument->hasDefaultValue())) {
return null;
}
return $this->serializer->denormalize($data, $argument->getType(), null, $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ['filter_bool' => true]);
return $this->serializer->denormalize($data, $argument->getType(), 'csv', $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ['filter_bool' => true]);
}
private function mapRequestPayload(Request $request, ArgumentMetadata $argument, MapRequestPayload $attribute): object|array|null
{
if ('' === ($data = $request->request->all() ?: $request->getContent()) && ($argument->isNullable() || $argument->hasDefaultValue())) {
return null;
}
if (null === $format = $request->getContentTypeFormat()) {
throw new UnsupportedMediaTypeHttpException('Unsupported format.');
}
if ($attribute->acceptFormat && !\in_array($format, (array) $attribute->acceptFormat, true)) {
throw new UnsupportedMediaTypeHttpException(sprintf('Unsupported format, expects "%s", but "%s" given.', implode('", "', (array) $attribute->acceptFormat), $format));
throw new UnsupportedMediaTypeHttpException(\sprintf('Unsupported format, expects "%s", but "%s" given.', implode('", "', (array) $attribute->acceptFormat), $format));
}
if ('array' === $argument->getType() && null !== $attribute->type) {
@@ -208,12 +226,8 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
$type = $argument->getType();
}
if ($data = $request->request->all()) {
return $this->serializer->denormalize($data, $type, null, $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ('form' === $format ? ['filter_bool' => true] : []));
}
if ('' === $data = $request->getContent()) {
return null;
if (\is_array($data)) {
return $this->serializer->denormalize($data, $type, self::hasNonStringScalar($data) ? $format : 'csv', $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ('form' === $format ? ['filter_bool' => true] : []));
}
if ('form' === $format) {
@@ -223,16 +237,41 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
try {
return $this->serializer->deserialize($data, $type, $format, self::CONTEXT_DESERIALIZE + $attribute->serializationContext);
} catch (UnsupportedFormatException $e) {
throw new UnsupportedMediaTypeHttpException(sprintf('Unsupported format: "%s".', $format), $e);
throw new UnsupportedMediaTypeHttpException(\sprintf('Unsupported format: "%s".', $format), $e);
} catch (NotEncodableValueException $e) {
throw new BadRequestHttpException(sprintf('Request payload contains invalid "%s" data.', $format), $e);
throw new BadRequestHttpException(\sprintf('Request payload contains invalid "%s" data.', $format), $e);
} catch (UnexpectedPropertyException $e) {
throw new BadRequestHttpException(sprintf('Request payload contains invalid "%s" property.', $e->property), $e);
throw new BadRequestHttpException(\sprintf('Request payload contains invalid "%s" property.', $e->property), $e);
}
}
private function mapUploadedFile(Request $request, ArgumentMetadata $argument, MapUploadedFile $attribute): UploadedFile|array|null
{
return $request->files->get($attribute->name ?? $argument->getName(), []);
if ($files = $request->files->get($attribute->name ?? $argument->getName())) {
return !\is_array($files) && $argument->isVariadic() ? [$files] : $files;
}
if ($argument->isNullable() || $argument->hasDefaultValue()) {
return null;
}
return 'array' === $argument->getType() ? [] : null;
}
private static function hasNonStringScalar(array $data): bool
{
$stack = [$data];
while ($stack) {
foreach (array_pop($stack) as $v) {
if (\is_array($v)) {
$stack[] = $v;
} elseif (!\is_string($v)) {
return true;
}
}
}
return false;
}
}