diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 4a342573..ad438091 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -24,6 +24,7 @@ ->in(__DIR__) ->exclude( [ + 'generated', 'tests/Application', ] ) diff --git a/composer.json b/composer.json index 398efe2e..524263ef 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ "phpstan/phpstan-doctrine": "^1.3.2", "phpstan/phpstan-webmozart-assert": "^1.1", "phpunit/phpunit": "^10.5", - "phpmd/phpmd": "^2.15" + "phpmd/phpmd": "^2.15", + "jane-php/json-schema": "^7.8" }, "prefer-stable": true, "autoload": { diff --git a/generated/Model/ChannelDTO.php b/generated/Model/ChannelDTO.php index dfa0250c..64029838 100644 --- a/generated/Model/ChannelDTO.php +++ b/generated/Model/ChannelDTO.php @@ -1,34 +1,43 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Model; class ChannelDTO { /** + * @var array + */ + protected $initialized = []; + public function isInitialized($property) : bool + { + return array_key_exists($property, $this->initialized); + } + /** + * + * * @var string */ protected $code; - - public function getCode(): string + /** + * + * + * @return string + */ + public function getCode() : string { return $this->code; } - - public function setCode(string $code): self + /** + * + * + * @param string $code + * + * @return self + */ + public function setCode(string $code) : self { + $this->initialized['code'] = true; $this->code = $code; - return $this; } -} +} \ No newline at end of file diff --git a/generated/Model/ImageDTO.php b/generated/Model/ImageDTO.php index e19a2d5c..188b83cb 100644 --- a/generated/Model/ImageDTO.php +++ b/generated/Model/ImageDTO.php @@ -1,34 +1,71 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Model; class ImageDTO { /** - * @var string|null + * @var array + */ + protected $initialized = []; + public function isInitialized($property) : bool + { + return array_key_exists($property, $this->initialized); + } + /** + * + * + * @var null|string */ protected $path; - - public function getPath(): ?string + /** + * + * + * @var null|string + */ + protected $type; + /** + * + * + * @return null|string + */ + public function getPath() : ?string { return $this->path; } - - public function setPath(?string $path): self + /** + * + * + * @param null|string $path + * + * @return self + */ + public function setPath(?string $path) : self { + $this->initialized['path'] = true; $this->path = $path; - return $this; } -} + /** + * + * + * @return null|string + */ + public function getType() : ?string + { + return $this->type; + } + /** + * + * + * @param null|string $type + * + * @return self + */ + public function setType(?string $type) : self + { + $this->initialized['type'] = true; + $this->type = $type; + return $this; + } +} \ No newline at end of file diff --git a/generated/Model/PricingDTO.php b/generated/Model/PricingDTO.php index a79f0d5f..61681166 100644 --- a/generated/Model/PricingDTO.php +++ b/generated/Model/PricingDTO.php @@ -1,85 +1,127 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Model; class PricingDTO { /** + * @var array + */ + protected $initialized = []; + public function isInitialized($property) : bool + { + return array_key_exists($property, $this->initialized); + } + /** + * + * * @var string */ protected $channelCode; - /** - * @var int|null + * + * + * @var null|int */ protected $price; - /** - * @var int|null + * + * + * @var null|int */ protected $originalPrice; - /** + * + * * @var bool */ protected $priceReduced; - - public function getChannelCode(): string + /** + * + * + * @return string + */ + public function getChannelCode() : string { return $this->channelCode; } - - public function setChannelCode(string $channelCode): self + /** + * + * + * @param string $channelCode + * + * @return self + */ + public function setChannelCode(string $channelCode) : self { + $this->initialized['channelCode'] = true; $this->channelCode = $channelCode; - return $this; } - - public function getPrice(): ?int + /** + * + * + * @return null|int + */ + public function getPrice() : ?int { return $this->price; } - - public function setPrice(?int $price): self + /** + * + * + * @param null|int $price + * + * @return self + */ + public function setPrice(?int $price) : self { + $this->initialized['price'] = true; $this->price = $price; - return $this; } - - public function getOriginalPrice(): ?int + /** + * + * + * @return null|int + */ + public function getOriginalPrice() : ?int { return $this->originalPrice; } - - public function setOriginalPrice(?int $originalPrice): self + /** + * + * + * @param null|int $originalPrice + * + * @return self + */ + public function setOriginalPrice(?int $originalPrice) : self { + $this->initialized['originalPrice'] = true; $this->originalPrice = $originalPrice; - return $this; } - - public function getPriceReduced(): bool + /** + * + * + * @return bool + */ + public function getPriceReduced() : bool { return $this->priceReduced; } - - public function setPriceReduced(bool $priceReduced): self + /** + * + * + * @param bool $priceReduced + * + * @return self + */ + public function setPriceReduced(bool $priceReduced) : self { + $this->initialized['priceReduced'] = true; $this->priceReduced = $priceReduced; - return $this; } -} +} \ No newline at end of file diff --git a/generated/Model/ProductAttributeDTO.php b/generated/Model/ProductAttributeDTO.php index c4225abf..3eeb09ef 100644 --- a/generated/Model/ProductAttributeDTO.php +++ b/generated/Model/ProductAttributeDTO.php @@ -1,74 +1,99 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Model; class ProductAttributeDTO { /** + * @var array + */ + protected $initialized = []; + public function isInitialized($property) : bool + { + return array_key_exists($property, $this->initialized); + } + /** + * + * * @var string */ protected $code; - /** + * + * * @var string */ protected $name; - /** - * @var mixed|null + * + * + * @var null|mixed */ protected $value; - - public function getCode(): string + /** + * + * + * @return string + */ + public function getCode() : string { return $this->code; } - - public function setCode(string $code): self + /** + * + * + * @param string $code + * + * @return self + */ + public function setCode(string $code) : self { + $this->initialized['code'] = true; $this->code = $code; - return $this; } - - public function getName(): string + /** + * + * + * @return string + */ + public function getName() : string { return $this->name; } - - public function setName(string $name): self + /** + * + * + * @param string $name + * + * @return self + */ + public function setName(string $name) : self { + $this->initialized['name'] = true; $this->name = $name; - return $this; } - /** - * @return mixed|null + * + * + * @return null|mixed */ public function getValue() { return $this->value; } - /** - * @param mixed|null $value + * + * + * @param null|mixed $value + * + * @return self */ - public function setValue($value): self + public function setValue($value) : self { + $this->initialized['value'] = true; $this->value = $value; - return $this; } -} +} \ No newline at end of file diff --git a/generated/Model/ProductTaxonDTO.php b/generated/Model/ProductTaxonDTO.php index 915a3dd6..ca774b07 100644 --- a/generated/Model/ProductTaxonDTO.php +++ b/generated/Model/ProductTaxonDTO.php @@ -1,51 +1,71 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Model; class ProductTaxonDTO { /** + * @var array + */ + protected $initialized = []; + public function isInitialized($property) : bool + { + return array_key_exists($property, $this->initialized); + } + /** + * + * * @var TaxonDTO */ protected $taxon; - /** - * @var int|null + * + * + * @var null|int */ protected $position; - - public function getTaxon(): TaxonDTO + /** + * + * + * @return TaxonDTO + */ + public function getTaxon() : TaxonDTO { return $this->taxon; } - - public function setTaxon(TaxonDTO $taxon): self + /** + * + * + * @param TaxonDTO $taxon + * + * @return self + */ + public function setTaxon(TaxonDTO $taxon) : self { + $this->initialized['taxon'] = true; $this->taxon = $taxon; - return $this; } - - public function getPosition(): ?int + /** + * + * + * @return null|int + */ + public function getPosition() : ?int { return $this->position; } - - public function setPosition(?int $position): self + /** + * + * + * @param null|int $position + * + * @return self + */ + public function setPosition(?int $position) : self { + $this->initialized['position'] = true; $this->position = $position; - return $this; } -} +} \ No newline at end of file diff --git a/generated/Model/TaxonDTO.php b/generated/Model/TaxonDTO.php index ed788d8a..98e8a3f9 100644 --- a/generated/Model/TaxonDTO.php +++ b/generated/Model/TaxonDTO.php @@ -1,85 +1,127 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Model; class TaxonDTO { /** + * @var array + */ + protected $initialized = []; + public function isInitialized($property) : bool + { + return array_key_exists($property, $this->initialized); + } + /** + * + * * @var string */ protected $name; - /** + * + * * @var string */ protected $code; - /** + * + * * @var int */ protected $position; - /** + * + * * @var int */ protected $level; - - public function getName(): string + /** + * + * + * @return string + */ + public function getName() : string { return $this->name; } - - public function setName(string $name): self + /** + * + * + * @param string $name + * + * @return self + */ + public function setName(string $name) : self { + $this->initialized['name'] = true; $this->name = $name; - return $this; } - - public function getCode(): string + /** + * + * + * @return string + */ + public function getCode() : string { return $this->code; } - - public function setCode(string $code): self + /** + * + * + * @param string $code + * + * @return self + */ + public function setCode(string $code) : self { + $this->initialized['code'] = true; $this->code = $code; - return $this; } - - public function getPosition(): int + /** + * + * + * @return int + */ + public function getPosition() : int { return $this->position; } - - public function setPosition(int $position): self + /** + * + * + * @param int $position + * + * @return self + */ + public function setPosition(int $position) : self { + $this->initialized['position'] = true; $this->position = $position; - return $this; } - - public function getLevel(): int + /** + * + * + * @return int + */ + public function getLevel() : int { return $this->level; } - - public function setLevel(int $level): self + /** + * + * + * @param int $level + * + * @return self + */ + public function setLevel(int $level) : self { + $this->initialized['level'] = true; $this->level = $level; - return $this; } -} +} \ No newline at end of file diff --git a/generated/Normalizer/ChannelDTONormalizer.php b/generated/Normalizer/ChannelDTONormalizer.php index 2ede3929..81df576e 100644 --- a/generated/Normalizer/ChannelDTONormalizer.php +++ b/generated/Normalizer/ChannelDTONormalizer.php @@ -1,69 +1,112 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer; use Jane\Component\JsonSchemaRuntime\Reference; use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\CheckArray; +use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\ValidatorTrait; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; - -class ChannelDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface -{ - use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; - - public function supportsDenormalization($data, $type, $format = null) - { - return 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ChannelDTO' === $type; - } - - public function supportsNormalization($data, $format = null) - { - return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO; - } - - public function denormalize($data, $class, $format = null, array $context = []) +use Symfony\Component\HttpKernel\Kernel; +if (!class_exists(Kernel::class) or (Kernel::MAJOR_VERSION >= 7 or Kernel::MAJOR_VERSION === 6 and Kernel::MINOR_VERSION === 4)) { + class ChannelDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - if (isset($data['$ref'])) { - return new Reference($data['$ref'], $context['document-origin']); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO::class; } - if (isset($data['$recursiveRef'])) { - return new Reference($data['$recursiveRef'], $context['document-origin']); + public function supportsNormalization(mixed $data, string $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO; } - $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO(); - if (null === $data || false === \is_array($data)) { + public function denormalize(mixed $data, string $type, string $format = null, array $context = []) : mixed + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('code', $data)) { + $object->setCode($data['code']); + } return $object; } - if (\array_key_exists('code', $data)) { - $object->setCode($data['code']); + public function normalize(mixed $object, string $format = null, array $context = []) : array|string|int|float|bool|\ArrayObject|null + { + $data = []; + if ($object->isInitialized('code') && null !== $object->getCode()) { + $data['code'] = $object->getCode(); + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO::class => false]; } - - return $object; } - - public function normalize($object, $format = null, array $context = []) +} else { + class ChannelDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - $data = []; - if (null !== $object->getCode()) { - $data['code'] = $object->getCode(); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization($data, $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO::class; + } + public function supportsNormalization($data, $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO; + } + /** + * @return mixed + */ + public function denormalize($data, $type, $format = null, array $context = []) + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('code', $data)) { + $object->setCode($data['code']); + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = []) + { + $data = []; + if ($object->isInitialized('code') && null !== $object->getCode()) { + $data['code'] = $object->getCode(); + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO::class => false]; } - - return $data; } -} +} \ No newline at end of file diff --git a/generated/Normalizer/ImageDTONormalizer.php b/generated/Normalizer/ImageDTONormalizer.php index 910779c0..afd66806 100644 --- a/generated/Normalizer/ImageDTONormalizer.php +++ b/generated/Normalizer/ImageDTONormalizer.php @@ -1,83 +1,184 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer; use Jane\Component\JsonSchemaRuntime\Reference; use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\CheckArray; +use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\ValidatorTrait; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; - -class ImageDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface -{ - use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; - - public function supportsDenormalization($data, $type, $format = null) +use Symfony\Component\HttpKernel\Kernel; +if (!class_exists(Kernel::class) or (Kernel::MAJOR_VERSION >= 7 or Kernel::MAJOR_VERSION === 6 and Kernel::MINOR_VERSION === 4)) { + class ImageDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - return 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ImageDTO' === $type; - } - - public function supportsNormalization($data, $format = null) - { - return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO; - } - - public function denormalize($data, $class, $format = null, array $context = []) - { - if (isset($data['$ref'])) { - return new Reference($data['$ref'], $context['document-origin']); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO::class; } - if (isset($data['$recursiveRef'])) { - return new Reference($data['$recursiveRef'], $context['document-origin']); + public function supportsNormalization(mixed $data, string $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO; } - $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO(); - if (null === $data || false === \is_array($data)) { + public function denormalize(mixed $data, string $type, string $format = null, array $context = []) : mixed + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('path', $data) && $data['path'] !== null) { + $value = $data['path']; + if (is_null($data['path'])) { + $value = $data['path']; + } elseif (is_string($data['path'])) { + $value = $data['path']; + } + $object->setPath($value); + } + elseif (\array_key_exists('path', $data) && $data['path'] === null) { + $object->setPath(null); + } + if (\array_key_exists('type', $data) && $data['type'] !== null) { + $value_1 = $data['type']; + if (is_null($data['type'])) { + $value_1 = $data['type']; + } elseif (is_string($data['type'])) { + $value_1 = $data['type']; + } + $object->setType($value_1); + } + elseif (\array_key_exists('type', $data) && $data['type'] === null) { + $object->setType(null); + } return $object; } - if (\array_key_exists('path', $data) && null !== $data['path']) { - $value = $data['path']; - if (null === $data['path']) { - $value = $data['path']; - } elseif (\is_string($data['path'])) { - $value = $data['path']; + public function normalize(mixed $object, string $format = null, array $context = []) : array|string|int|float|bool|\ArrayObject|null + { + $data = []; + if ($object->isInitialized('path') && null !== $object->getPath()) { + $value = $object->getPath(); + if (is_null($object->getPath())) { + $value = $object->getPath(); + } elseif (is_string($object->getPath())) { + $value = $object->getPath(); + } + $data['path'] = $value; } - $object->setPath($value); - } elseif (\array_key_exists('path', $data) && null === $data['path']) { - $object->setPath(null); + if ($object->isInitialized('type') && null !== $object->getType()) { + $value_1 = $object->getType(); + if (is_null($object->getType())) { + $value_1 = $object->getType(); + } elseif (is_string($object->getType())) { + $value_1 = $object->getType(); + } + $data['type'] = $value_1; + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO::class => false]; } - - return $object; } - - public function normalize($object, $format = null, array $context = []) +} else { + class ImageDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - $data = []; - if (null !== $object->getPath()) { - $value = $object->getPath(); - if (null === $object->getPath()) { - $value = $object->getPath(); - } elseif (\is_string($object->getPath())) { + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization($data, $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO::class; + } + public function supportsNormalization($data, $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO; + } + /** + * @return mixed + */ + public function denormalize($data, $type, $format = null, array $context = []) + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('path', $data) && $data['path'] !== null) { + $value = $data['path']; + if (is_null($data['path'])) { + $value = $data['path']; + } elseif (is_string($data['path'])) { + $value = $data['path']; + } + $object->setPath($value); + } + elseif (\array_key_exists('path', $data) && $data['path'] === null) { + $object->setPath(null); + } + if (\array_key_exists('type', $data) && $data['type'] !== null) { + $value_1 = $data['type']; + if (is_null($data['type'])) { + $value_1 = $data['type']; + } elseif (is_string($data['type'])) { + $value_1 = $data['type']; + } + $object->setType($value_1); + } + elseif (\array_key_exists('type', $data) && $data['type'] === null) { + $object->setType(null); + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = []) + { + $data = []; + if ($object->isInitialized('path') && null !== $object->getPath()) { $value = $object->getPath(); + if (is_null($object->getPath())) { + $value = $object->getPath(); + } elseif (is_string($object->getPath())) { + $value = $object->getPath(); + } + $data['path'] = $value; + } + if ($object->isInitialized('type') && null !== $object->getType()) { + $value_1 = $object->getType(); + if (is_null($object->getType())) { + $value_1 = $object->getType(); + } elseif (is_string($object->getType())) { + $value_1 = $object->getType(); + } + $data['type'] = $value_1; } - $data['path'] = $value; + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO::class => false]; } - - return $data; } -} +} \ No newline at end of file diff --git a/generated/Normalizer/JaneObjectNormalizer.php b/generated/Normalizer/JaneObjectNormalizer.php index e9ce3c27..84e4c4da 100644 --- a/generated/Normalizer/JaneObjectNormalizer.php +++ b/generated/Normalizer/JaneObjectNormalizer.php @@ -1,74 +1,158 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer; use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\CheckArray; +use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\ValidatorTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; - -class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface -{ - use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; - - protected $normalizers = ['MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ImageDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ImageDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ChannelDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ChannelDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ProductTaxonDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ProductTaxonDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\TaxonDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\TaxonDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ProductAttributeDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ProductAttributeDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\PricingDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\PricingDTONormalizer', '\\Jane\\Component\\JsonSchemaRuntime\\Reference' => '\\MonsieurBiz\\SyliusSearchPlugin\\Generated\\Runtime\\Normalizer\\ReferenceNormalizer']; - - protected $normalizersCache = []; - - public function supportsDenormalization($data, $type, $format = null) - { - return \array_key_exists($type, $this->normalizers); - } - - public function supportsNormalization($data, $format = null) - { - return \is_object($data) && \array_key_exists($data::class, $this->normalizers); - } - - public function normalize($object, $format = null, array $context = []) +use Symfony\Component\HttpKernel\Kernel; +if (!class_exists(Kernel::class) or (Kernel::MAJOR_VERSION >= 7 or Kernel::MAJOR_VERSION === 6 and Kernel::MINOR_VERSION === 4)) { + class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - $normalizerClass = $this->normalizers[$object::class]; - $normalizer = $this->getNormalizer($normalizerClass); - - return $normalizer->normalize($object, $format, $context); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + protected $normalizers = [ + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\ImageDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\ChannelDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\ProductTaxonDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\TaxonDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\ProductAttributeDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\PricingDTONormalizer::class, + + \Jane\Component\JsonSchemaRuntime\Reference::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\ReferenceNormalizer::class, + ], $normalizersCache = []; + public function supportsDenormalization($data, $type, $format = null, array $context = []) : bool + { + return array_key_exists($type, $this->normalizers); + } + public function supportsNormalization($data, $format = null, array $context = []) : bool + { + return is_object($data) && array_key_exists(get_class($data), $this->normalizers); + } + public function normalize(mixed $object, string $format = null, array $context = []) : array|string|int|float|bool|\ArrayObject|null + { + $normalizerClass = $this->normalizers[get_class($object)]; + $normalizer = $this->getNormalizer($normalizerClass); + return $normalizer->normalize($object, $format, $context); + } + public function denormalize(mixed $data, string $type, string $format = null, array $context = []) : mixed + { + $denormalizerClass = $this->normalizers[$type]; + $denormalizer = $this->getNormalizer($denormalizerClass); + return $denormalizer->denormalize($data, $type, $format, $context); + } + private function getNormalizer(string $normalizerClass) + { + return $this->normalizersCache[$normalizerClass] ?? $this->initNormalizer($normalizerClass); + } + private function initNormalizer(string $normalizerClass) + { + $normalizer = new $normalizerClass(); + $normalizer->setNormalizer($this->normalizer); + $normalizer->setDenormalizer($this->denormalizer); + $this->normalizersCache[$normalizerClass] = $normalizer; + return $normalizer; + } + public function getSupportedTypes(?string $format = null) : array + { + return [ + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO::class => false, + \Jane\Component\JsonSchemaRuntime\Reference::class => false, + ]; + } } - - public function denormalize($data, $class, $format = null, array $context = []) +} else { + class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - $denormalizerClass = $this->normalizers[$class]; - $denormalizer = $this->getNormalizer($denormalizerClass); - - return $denormalizer->denormalize($data, $class, $format, $context); - } - - private function getNormalizer(string $normalizerClass) - { - return $this->normalizersCache[$normalizerClass] ?? $this->initNormalizer($normalizerClass); - } - - private function initNormalizer(string $normalizerClass) - { - $normalizer = new $normalizerClass(); - $normalizer->setNormalizer($this->normalizer); - $normalizer->setDenormalizer($this->denormalizer); - $this->normalizersCache[$normalizerClass] = $normalizer; - - return $normalizer; + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + protected $normalizers = [ + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\ImageDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\ChannelDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\ProductTaxonDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\TaxonDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\ProductAttributeDTONormalizer::class, + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer\PricingDTONormalizer::class, + + \Jane\Component\JsonSchemaRuntime\Reference::class => \MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\ReferenceNormalizer::class, + ], $normalizersCache = []; + public function supportsDenormalization($data, $type, $format = null, array $context = []) : bool + { + return array_key_exists($type, $this->normalizers); + } + public function supportsNormalization($data, $format = null, array $context = []) : bool + { + return is_object($data) && array_key_exists(get_class($data), $this->normalizers); + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = []) + { + $normalizerClass = $this->normalizers[get_class($object)]; + $normalizer = $this->getNormalizer($normalizerClass); + return $normalizer->normalize($object, $format, $context); + } + /** + * @return mixed + */ + public function denormalize($data, $type, $format = null, array $context = []) + { + $denormalizerClass = $this->normalizers[$type]; + $denormalizer = $this->getNormalizer($denormalizerClass); + return $denormalizer->denormalize($data, $type, $format, $context); + } + private function getNormalizer(string $normalizerClass) + { + return $this->normalizersCache[$normalizerClass] ?? $this->initNormalizer($normalizerClass); + } + private function initNormalizer(string $normalizerClass) + { + $normalizer = new $normalizerClass(); + $normalizer->setNormalizer($this->normalizer); + $normalizer->setDenormalizer($this->denormalizer); + $this->normalizersCache[$normalizerClass] = $normalizer; + return $normalizer; + } + public function getSupportedTypes(?string $format = null) : array + { + return [ + + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ImageDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ChannelDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO::class => false, + \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO::class => false, + \Jane\Component\JsonSchemaRuntime\Reference::class => false, + ]; + } } -} +} \ No newline at end of file diff --git a/generated/Normalizer/PricingDTONormalizer.php b/generated/Normalizer/PricingDTONormalizer.php index 69183914..7789c1c0 100644 --- a/generated/Normalizer/PricingDTONormalizer.php +++ b/generated/Normalizer/PricingDTONormalizer.php @@ -1,123 +1,224 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer; use Jane\Component\JsonSchemaRuntime\Reference; use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\CheckArray; +use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\ValidatorTrait; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; - -class PricingDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface -{ - use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; - - public function supportsDenormalization($data, $type, $format = null) +use Symfony\Component\HttpKernel\Kernel; +if (!class_exists(Kernel::class) or (Kernel::MAJOR_VERSION >= 7 or Kernel::MAJOR_VERSION === 6 and Kernel::MINOR_VERSION === 4)) { + class PricingDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - return 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\PricingDTO' === $type; - } - - public function supportsNormalization($data, $format = null) - { - return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO; - } - - public function denormalize($data, $class, $format = null, array $context = []) - { - if (isset($data['$ref'])) { - return new Reference($data['$ref'], $context['document-origin']); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO::class; } - if (isset($data['$recursiveRef'])) { - return new Reference($data['$recursiveRef'], $context['document-origin']); - } - $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO(); - if (null === $data || false === \is_array($data)) { - return $object; + public function supportsNormalization(mixed $data, string $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO; } - if (\array_key_exists('channel_code', $data)) { - $object->setChannelCode($data['channel_code']); - } - if (\array_key_exists('price', $data) && null !== $data['price']) { - $value = $data['price']; - if (null === $data['price']) { - $value = $data['price']; - } elseif (\is_int($data['price'])) { + public function denormalize(mixed $data, string $type, string $format = null, array $context = []) : mixed + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('channel_code', $data)) { + $object->setChannelCode($data['channel_code']); + } + if (\array_key_exists('price', $data) && $data['price'] !== null) { $value = $data['price']; + if (is_null($data['price'])) { + $value = $data['price']; + } elseif (is_int($data['price'])) { + $value = $data['price']; + } + $object->setPrice($value); } - $object->setPrice($value); - } elseif (\array_key_exists('price', $data) && null === $data['price']) { - $object->setPrice(null); - } - if (\array_key_exists('original_price', $data) && null !== $data['original_price']) { - $value_1 = $data['original_price']; - if (null === $data['original_price']) { - $value_1 = $data['original_price']; - } elseif (\is_int($data['original_price'])) { + elseif (\array_key_exists('price', $data) && $data['price'] === null) { + $object->setPrice(null); + } + if (\array_key_exists('original_price', $data) && $data['original_price'] !== null) { $value_1 = $data['original_price']; + if (is_null($data['original_price'])) { + $value_1 = $data['original_price']; + } elseif (is_int($data['original_price'])) { + $value_1 = $data['original_price']; + } + $object->setOriginalPrice($value_1); } - $object->setOriginalPrice($value_1); - } elseif (\array_key_exists('original_price', $data) && null === $data['original_price']) { - $object->setOriginalPrice(null); - } - if (\array_key_exists('price_reduced', $data)) { - $value_2 = $data['price_reduced']; - if (\is_bool($data['price_reduced'])) { + elseif (\array_key_exists('original_price', $data) && $data['original_price'] === null) { + $object->setOriginalPrice(null); + } + if (\array_key_exists('price_reduced', $data)) { $value_2 = $data['price_reduced']; + if (is_bool($data['price_reduced'])) { + $value_2 = $data['price_reduced']; + } + $object->setPriceReduced($value_2); } - $object->setPriceReduced($value_2); + return $object; + } + public function normalize(mixed $object, string $format = null, array $context = []) : array|string|int|float|bool|\ArrayObject|null + { + $data = []; + if ($object->isInitialized('channelCode') && null !== $object->getChannelCode()) { + $data['channel_code'] = $object->getChannelCode(); + } + if ($object->isInitialized('price') && null !== $object->getPrice()) { + $value = $object->getPrice(); + if (is_null($object->getPrice())) { + $value = $object->getPrice(); + } elseif (is_int($object->getPrice())) { + $value = $object->getPrice(); + } + $data['price'] = $value; + } + if ($object->isInitialized('originalPrice') && null !== $object->getOriginalPrice()) { + $value_1 = $object->getOriginalPrice(); + if (is_null($object->getOriginalPrice())) { + $value_1 = $object->getOriginalPrice(); + } elseif (is_int($object->getOriginalPrice())) { + $value_1 = $object->getOriginalPrice(); + } + $data['original_price'] = $value_1; + } + if ($object->isInitialized('priceReduced') && null !== $object->getPriceReduced()) { + $value_2 = $object->getPriceReduced(); + if (is_bool($object->getPriceReduced())) { + $value_2 = $object->getPriceReduced(); + } + $data['price_reduced'] = $value_2; + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO::class => false]; } - - return $object; } - - public function normalize($object, $format = null, array $context = []) +} else { + class PricingDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - $data = []; - if (null !== $object->getChannelCode()) { - $data['channel_code'] = $object->getChannelCode(); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization($data, $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO::class; } - if (null !== $object->getPrice()) { - $value = $object->getPrice(); - if (null === $object->getPrice()) { - $value = $object->getPrice(); - } elseif (\is_int($object->getPrice())) { - $value = $object->getPrice(); + public function supportsNormalization($data, $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO; + } + /** + * @return mixed + */ + public function denormalize($data, $type, $format = null, array $context = []) + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('channel_code', $data)) { + $object->setChannelCode($data['channel_code']); + } + if (\array_key_exists('price', $data) && $data['price'] !== null) { + $value = $data['price']; + if (is_null($data['price'])) { + $value = $data['price']; + } elseif (is_int($data['price'])) { + $value = $data['price']; + } + $object->setPrice($value); } - $data['price'] = $value; + elseif (\array_key_exists('price', $data) && $data['price'] === null) { + $object->setPrice(null); + } + if (\array_key_exists('original_price', $data) && $data['original_price'] !== null) { + $value_1 = $data['original_price']; + if (is_null($data['original_price'])) { + $value_1 = $data['original_price']; + } elseif (is_int($data['original_price'])) { + $value_1 = $data['original_price']; + } + $object->setOriginalPrice($value_1); + } + elseif (\array_key_exists('original_price', $data) && $data['original_price'] === null) { + $object->setOriginalPrice(null); + } + if (\array_key_exists('price_reduced', $data)) { + $value_2 = $data['price_reduced']; + if (is_bool($data['price_reduced'])) { + $value_2 = $data['price_reduced']; + } + $object->setPriceReduced($value_2); + } + return $object; } - if (null !== $object->getOriginalPrice()) { - $value_1 = $object->getOriginalPrice(); - if (null === $object->getOriginalPrice()) { - $value_1 = $object->getOriginalPrice(); - } elseif (\is_int($object->getOriginalPrice())) { + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = []) + { + $data = []; + if ($object->isInitialized('channelCode') && null !== $object->getChannelCode()) { + $data['channel_code'] = $object->getChannelCode(); + } + if ($object->isInitialized('price') && null !== $object->getPrice()) { + $value = $object->getPrice(); + if (is_null($object->getPrice())) { + $value = $object->getPrice(); + } elseif (is_int($object->getPrice())) { + $value = $object->getPrice(); + } + $data['price'] = $value; + } + if ($object->isInitialized('originalPrice') && null !== $object->getOriginalPrice()) { $value_1 = $object->getOriginalPrice(); + if (is_null($object->getOriginalPrice())) { + $value_1 = $object->getOriginalPrice(); + } elseif (is_int($object->getOriginalPrice())) { + $value_1 = $object->getOriginalPrice(); + } + $data['original_price'] = $value_1; } - $data['original_price'] = $value_1; - } - if (null !== $object->getPriceReduced()) { - $value_2 = $object->getPriceReduced(); - if (\is_bool($object->getPriceReduced())) { + if ($object->isInitialized('priceReduced') && null !== $object->getPriceReduced()) { $value_2 = $object->getPriceReduced(); + if (is_bool($object->getPriceReduced())) { + $value_2 = $object->getPriceReduced(); + } + $data['price_reduced'] = $value_2; } - $data['price_reduced'] = $value_2; + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\PricingDTO::class => false]; } - - return $data; } -} +} \ No newline at end of file diff --git a/generated/Normalizer/ProductAttributeDTONormalizer.php b/generated/Normalizer/ProductAttributeDTONormalizer.php index f101084a..9df33514 100644 --- a/generated/Normalizer/ProductAttributeDTONormalizer.php +++ b/generated/Normalizer/ProductAttributeDTONormalizer.php @@ -1,95 +1,166 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer; use Jane\Component\JsonSchemaRuntime\Reference; use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\CheckArray; +use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\ValidatorTrait; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; - -class ProductAttributeDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface -{ - use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; - - public function supportsDenormalization($data, $type, $format = null) +use Symfony\Component\HttpKernel\Kernel; +if (!class_exists(Kernel::class) or (Kernel::MAJOR_VERSION >= 7 or Kernel::MAJOR_VERSION === 6 and Kernel::MINOR_VERSION === 4)) { + class ProductAttributeDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - return 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ProductAttributeDTO' === $type; - } - - public function supportsNormalization($data, $format = null) - { - return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO; - } - - public function denormalize($data, $class, $format = null, array $context = []) - { - if (isset($data['$ref'])) { - return new Reference($data['$ref'], $context['document-origin']); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO::class; } - if (isset($data['$recursiveRef'])) { - return new Reference($data['$recursiveRef'], $context['document-origin']); + public function supportsNormalization(mixed $data, string $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO; } - $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO(); - if (null === $data || false === \is_array($data)) { + public function denormalize(mixed $data, string $type, string $format = null, array $context = []) : mixed + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('code', $data)) { + $object->setCode($data['code']); + } + if (\array_key_exists('name', $data)) { + $object->setName($data['name']); + } + if (\array_key_exists('value', $data) && $data['value'] !== null) { + $value = $data['value']; + if (is_null($data['value'])) { + $value = $data['value']; + } elseif (isset($data['value'])) { + $value = $data['value']; + } + $object->setValue($value); + } + elseif (\array_key_exists('value', $data) && $data['value'] === null) { + $object->setValue(null); + } return $object; } - if (\array_key_exists('code', $data)) { - $object->setCode($data['code']); - } - if (\array_key_exists('name', $data)) { - $object->setName($data['name']); - } - if (\array_key_exists('value', $data) && null !== $data['value']) { - $value = $data['value']; - if (null === $data['value']) { - $value = $data['value']; - } elseif (isset($data['value'])) { - $value = $data['value']; + public function normalize(mixed $object, string $format = null, array $context = []) : array|string|int|float|bool|\ArrayObject|null + { + $data = []; + if ($object->isInitialized('code') && null !== $object->getCode()) { + $data['code'] = $object->getCode(); } - $object->setValue($value); - } elseif (\array_key_exists('value', $data) && null === $data['value']) { - $object->setValue(null); + if ($object->isInitialized('name') && null !== $object->getName()) { + $data['name'] = $object->getName(); + } + if ($object->isInitialized('value') && null !== $object->getValue()) { + $value = $object->getValue(); + if (is_null($object->getValue())) { + $value = $object->getValue(); + } elseif (!is_null($object->getValue())) { + $value = $object->getValue(); + } + $data['value'] = $value; + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO::class => false]; } - - return $object; } - - public function normalize($object, $format = null, array $context = []) +} else { + class ProductAttributeDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - $data = []; - if (null !== $object->getCode()) { - $data['code'] = $object->getCode(); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization($data, $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO::class; } - if (null !== $object->getName()) { - $data['name'] = $object->getName(); + public function supportsNormalization($data, $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO; } - if (null !== $object->getValue()) { - $value = $object->getValue(); - if (null === $object->getValue()) { - $value = $object->getValue(); - } elseif (null !== $object->getValue()) { + /** + * @return mixed + */ + public function denormalize($data, $type, $format = null, array $context = []) + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('code', $data)) { + $object->setCode($data['code']); + } + if (\array_key_exists('name', $data)) { + $object->setName($data['name']); + } + if (\array_key_exists('value', $data) && $data['value'] !== null) { + $value = $data['value']; + if (is_null($data['value'])) { + $value = $data['value']; + } elseif (isset($data['value'])) { + $value = $data['value']; + } + $object->setValue($value); + } + elseif (\array_key_exists('value', $data) && $data['value'] === null) { + $object->setValue(null); + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = []) + { + $data = []; + if ($object->isInitialized('code') && null !== $object->getCode()) { + $data['code'] = $object->getCode(); + } + if ($object->isInitialized('name') && null !== $object->getName()) { + $data['name'] = $object->getName(); + } + if ($object->isInitialized('value') && null !== $object->getValue()) { $value = $object->getValue(); + if (is_null($object->getValue())) { + $value = $object->getValue(); + } elseif (!is_null($object->getValue())) { + $value = $object->getValue(); + } + $data['value'] = $value; } - $data['value'] = $value; + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductAttributeDTO::class => false]; } - - return $data; } -} +} \ No newline at end of file diff --git a/generated/Normalizer/ProductTaxonDTONormalizer.php b/generated/Normalizer/ProductTaxonDTONormalizer.php index 2201b2ea..2cad8699 100644 --- a/generated/Normalizer/ProductTaxonDTONormalizer.php +++ b/generated/Normalizer/ProductTaxonDTONormalizer.php @@ -1,89 +1,154 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer; use Jane\Component\JsonSchemaRuntime\Reference; use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\CheckArray; +use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\ValidatorTrait; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; - -class ProductTaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface -{ - use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; - - public function supportsDenormalization($data, $type, $format = null) - { - return 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ProductTaxonDTO' === $type; - } - - public function supportsNormalization($data, $format = null) - { - return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO; - } - - public function denormalize($data, $class, $format = null, array $context = []) +use Symfony\Component\HttpKernel\Kernel; +if (!class_exists(Kernel::class) or (Kernel::MAJOR_VERSION >= 7 or Kernel::MAJOR_VERSION === 6 and Kernel::MINOR_VERSION === 4)) { + class ProductTaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - if (isset($data['$ref'])) { - return new Reference($data['$ref'], $context['document-origin']); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO::class; } - if (isset($data['$recursiveRef'])) { - return new Reference($data['$recursiveRef'], $context['document-origin']); + public function supportsNormalization(mixed $data, string $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO; } - $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO(); - if (null === $data || false === \is_array($data)) { + public function denormalize(mixed $data, string $type, string $format = null, array $context = []) : mixed + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('taxon', $data)) { + $object->setTaxon($this->denormalizer->denormalize($data['taxon'], \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class, 'json', $context)); + } + if (\array_key_exists('position', $data) && $data['position'] !== null) { + $value = $data['position']; + if (is_null($data['position'])) { + $value = $data['position']; + } elseif (is_int($data['position'])) { + $value = $data['position']; + } + $object->setPosition($value); + } + elseif (\array_key_exists('position', $data) && $data['position'] === null) { + $object->setPosition(null); + } return $object; } - if (\array_key_exists('taxon', $data)) { - $object->setTaxon($this->denormalizer->denormalize($data['taxon'], 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\TaxonDTO', 'json', $context)); - } - if (\array_key_exists('position', $data) && null !== $data['position']) { - $value = $data['position']; - if (null === $data['position']) { - $value = $data['position']; - } elseif (\is_int($data['position'])) { - $value = $data['position']; + public function normalize(mixed $object, string $format = null, array $context = []) : array|string|int|float|bool|\ArrayObject|null + { + $data = []; + if ($object->isInitialized('taxon') && null !== $object->getTaxon()) { + $data['taxon'] = $this->normalizer->normalize($object->getTaxon(), 'json', $context); } - $object->setPosition($value); - } elseif (\array_key_exists('position', $data) && null === $data['position']) { - $object->setPosition(null); + if ($object->isInitialized('position') && null !== $object->getPosition()) { + $value = $object->getPosition(); + if (is_null($object->getPosition())) { + $value = $object->getPosition(); + } elseif (is_int($object->getPosition())) { + $value = $object->getPosition(); + } + $data['position'] = $value; + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO::class => false]; } - - return $object; } - - public function normalize($object, $format = null, array $context = []) +} else { + class ProductTaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - $data = []; - if (null !== $object->getTaxon()) { - $data['taxon'] = $this->normalizer->normalize($object->getTaxon(), 'json', $context); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization($data, $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO::class; } - if (null !== $object->getPosition()) { - $value = $object->getPosition(); - if (null === $object->getPosition()) { - $value = $object->getPosition(); - } elseif (\is_int($object->getPosition())) { + public function supportsNormalization($data, $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO; + } + /** + * @return mixed + */ + public function denormalize($data, $type, $format = null, array $context = []) + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('taxon', $data)) { + $object->setTaxon($this->denormalizer->denormalize($data['taxon'], \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class, 'json', $context)); + } + if (\array_key_exists('position', $data) && $data['position'] !== null) { + $value = $data['position']; + if (is_null($data['position'])) { + $value = $data['position']; + } elseif (is_int($data['position'])) { + $value = $data['position']; + } + $object->setPosition($value); + } + elseif (\array_key_exists('position', $data) && $data['position'] === null) { + $object->setPosition(null); + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = []) + { + $data = []; + if ($object->isInitialized('taxon') && null !== $object->getTaxon()) { + $data['taxon'] = $this->normalizer->normalize($object->getTaxon(), 'json', $context); + } + if ($object->isInitialized('position') && null !== $object->getPosition()) { $value = $object->getPosition(); + if (is_null($object->getPosition())) { + $value = $object->getPosition(); + } elseif (is_int($object->getPosition())) { + $value = $object->getPosition(); + } + $data['position'] = $value; } - $data['position'] = $value; + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\ProductTaxonDTO::class => false]; } - - return $data; } -} +} \ No newline at end of file diff --git a/generated/Normalizer/TaxonDTONormalizer.php b/generated/Normalizer/TaxonDTONormalizer.php index 95e88f37..504640f3 100644 --- a/generated/Normalizer/TaxonDTONormalizer.php +++ b/generated/Normalizer/TaxonDTONormalizer.php @@ -1,87 +1,148 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Normalizer; use Jane\Component\JsonSchemaRuntime\Reference; use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\CheckArray; +use MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer\ValidatorTrait; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; - -class TaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface -{ - use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; - - public function supportsDenormalization($data, $type, $format = null) +use Symfony\Component\HttpKernel\Kernel; +if (!class_exists(Kernel::class) or (Kernel::MAJOR_VERSION >= 7 or Kernel::MAJOR_VERSION === 6 and Kernel::MINOR_VERSION === 4)) { + class TaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - return 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\TaxonDTO' === $type; - } - - public function supportsNormalization($data, $format = null) - { - return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO; - } - - public function denormalize($data, $class, $format = null, array $context = []) - { - if (isset($data['$ref'])) { - return new Reference($data['$ref'], $context['document-origin']); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class; } - if (isset($data['$recursiveRef'])) { - return new Reference($data['$recursiveRef'], $context['document-origin']); + public function supportsNormalization(mixed $data, string $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO; } - $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO(); - if (null === $data || false === \is_array($data)) { + public function denormalize(mixed $data, string $type, string $format = null, array $context = []) : mixed + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('name', $data)) { + $object->setName($data['name']); + } + if (\array_key_exists('code', $data)) { + $object->setCode($data['code']); + } + if (\array_key_exists('position', $data)) { + $object->setPosition($data['position']); + } + if (\array_key_exists('level', $data)) { + $object->setLevel($data['level']); + } return $object; } - if (\array_key_exists('name', $data)) { - $object->setName($data['name']); - } - if (\array_key_exists('code', $data)) { - $object->setCode($data['code']); + public function normalize(mixed $object, string $format = null, array $context = []) : array|string|int|float|bool|\ArrayObject|null + { + $data = []; + if ($object->isInitialized('name') && null !== $object->getName()) { + $data['name'] = $object->getName(); + } + if ($object->isInitialized('code') && null !== $object->getCode()) { + $data['code'] = $object->getCode(); + } + if ($object->isInitialized('position') && null !== $object->getPosition()) { + $data['position'] = $object->getPosition(); + } + if ($object->isInitialized('level') && null !== $object->getLevel()) { + $data['level'] = $object->getLevel(); + } + return $data; } - if (\array_key_exists('position', $data)) { - $object->setPosition($data['position']); + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class => false]; } - if (\array_key_exists('level', $data)) { - $object->setLevel($data['level']); - } - - return $object; } - - public function normalize($object, $format = null, array $context = []) +} else { + class TaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { - $data = []; - if (null !== $object->getName()) { - $data['name'] = $object->getName(); + use DenormalizerAwareTrait; + use NormalizerAwareTrait; + use CheckArray; + use ValidatorTrait; + public function supportsDenormalization($data, $type, string $format = null, array $context = []) : bool + { + return $type === \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class; + } + public function supportsNormalization($data, $format = null, array $context = []) : bool + { + return $data instanceof \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO; } - if (null !== $object->getCode()) { - $data['code'] = $object->getCode(); + /** + * @return mixed + */ + public function denormalize($data, $type, $format = null, array $context = []) + { + if (isset($data['$ref'])) { + return new Reference($data['$ref'], $context['document-origin']); + } + if (isset($data['$recursiveRef'])) { + return new Reference($data['$recursiveRef'], $context['document-origin']); + } + $object = new \MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO(); + if (null === $data || false === \is_array($data)) { + return $object; + } + if (\array_key_exists('name', $data)) { + $object->setName($data['name']); + } + if (\array_key_exists('code', $data)) { + $object->setCode($data['code']); + } + if (\array_key_exists('position', $data)) { + $object->setPosition($data['position']); + } + if (\array_key_exists('level', $data)) { + $object->setLevel($data['level']); + } + return $object; } - if (null !== $object->getPosition()) { - $data['position'] = $object->getPosition(); + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = []) + { + $data = []; + if ($object->isInitialized('name') && null !== $object->getName()) { + $data['name'] = $object->getName(); + } + if ($object->isInitialized('code') && null !== $object->getCode()) { + $data['code'] = $object->getCode(); + } + if ($object->isInitialized('position') && null !== $object->getPosition()) { + $data['position'] = $object->getPosition(); + } + if ($object->isInitialized('level') && null !== $object->getLevel()) { + $data['level'] = $object->getLevel(); + } + return $data; } - if (null !== $object->getLevel()) { - $data['level'] = $object->getLevel(); + public function getSupportedTypes(?string $format = null) : array + { + return [\MonsieurBiz\SyliusSearchPlugin\Generated\Model\TaxonDTO::class => false]; } - - return $data; } -} +} \ No newline at end of file diff --git a/generated/Runtime/Normalizer/CheckArray.php b/generated/Runtime/Normalizer/CheckArray.php index db91ddff..4e48da3d 100644 --- a/generated/Runtime/Normalizer/CheckArray.php +++ b/generated/Runtime/Normalizer/CheckArray.php @@ -1,24 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer; trait CheckArray { - public function isOnlyNumericKeys(array $array): bool + public function isOnlyNumericKeys(array $array) : bool { - return \count(array_filter($array, function ($key) { + return count(array_filter($array, function ($key) { return is_numeric($key); - }, \ARRAY_FILTER_USE_KEY)) === \count($array); + }, ARRAY_FILTER_USE_KEY)) === count($array); } -} +} \ No newline at end of file diff --git a/generated/Runtime/Normalizer/ReferenceNormalizer.php b/generated/Runtime/Normalizer/ReferenceNormalizer.php index e7d978e6..91c1afce 100644 --- a/generated/Runtime/Normalizer/ReferenceNormalizer.php +++ b/generated/Runtime/Normalizer/ReferenceNormalizer.php @@ -1,39 +1,48 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - namespace MonsieurBiz\SyliusSearchPlugin\Generated\Runtime\Normalizer; use Jane\Component\JsonSchemaRuntime\Reference; +use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; - -class ReferenceNormalizer implements NormalizerInterface -{ - /** - * @inheritdoc - */ - public function normalize($object, $format = null, array $context = []) +if (Kernel::MAJOR_VERSION >= 7 || Kernel::MAJOR_VERSION === 6 && Kernel::MINOR_VERSION === 4) { + class ReferenceNormalizer implements NormalizerInterface { - $ref = []; - $ref['$ref'] = (string) $object->getReferenceUri(); - - return $ref; + /** + * {@inheritdoc} + */ + public function normalize(mixed $object, string $format = null, array $context = []) : array|string|int|float|bool|\ArrayObject|null + { + $ref = []; + $ref['$ref'] = (string) $object->getReferenceUri(); + return $ref; + } + /** + * {@inheritdoc} + */ + public function supportsNormalization($data, $format = null) : bool + { + return $data instanceof Reference; + } } - - /** - * @inheritdoc - */ - public function supportsNormalization($data, $format = null) +} else { + class ReferenceNormalizer implements NormalizerInterface { - return $data instanceof Reference; + /** + * {@inheritdoc} + */ + public function normalize($object, $format = null, array $context = []) + { + $ref = []; + $ref['$ref'] = (string) $object->getReferenceUri(); + return $ref; + } + /** + * {@inheritdoc} + */ + public function supportsNormalization($data, $format = null) : bool + { + return $data instanceof Reference; + } } -} +} \ No newline at end of file diff --git a/generated/Runtime/Normalizer/ValidationException.php b/generated/Runtime/Normalizer/ValidationException.php new file mode 100644 index 00000000..172cf52c --- /dev/null +++ b/generated/Runtime/Normalizer/ValidationException.php @@ -0,0 +1,20 @@ +violationList = $violationList; + parent::__construct(sprintf('Model validation failed with %d errors.', $violationList->count()), 400); + } + public function getViolationList() : ConstraintViolationListInterface + { + return $this->violationList; + } +} \ No newline at end of file diff --git a/generated/Runtime/Normalizer/ValidatorTrait.php b/generated/Runtime/Normalizer/ValidatorTrait.php new file mode 100644 index 00000000..3b9b62a7 --- /dev/null +++ b/generated/Runtime/Normalizer/ValidatorTrait.php @@ -0,0 +1,17 @@ +validate($data, $constraint); + if ($violations->count() > 0) { + throw new ValidationException($violations); + } + } +} \ No newline at end of file diff --git a/src/Model/Product/ProductDTO.php b/src/Model/Product/ProductDTO.php index a5bad0ef..3622e873 100644 --- a/src/Model/Product/ProductDTO.php +++ b/src/Model/Product/ProductDTO.php @@ -17,4 +17,15 @@ class ProductDTO extends Eater { + public function getImagesByType(string $type): array + { + $images = $this->getData('images') ?? []; + if (!\is_array($images)) { + return []; + } + + return array_filter($images, function ($image) use ($type) { + return \is_object($image) && method_exists($image, 'getType') && $image->getType() === $type; + }); + } } diff --git a/src/Resources/config/jane/json-schema.json b/src/Resources/config/jane/json-schema.json index dc30a8c9..8af59db8 100644 --- a/src/Resources/config/jane/json-schema.json +++ b/src/Resources/config/jane/json-schema.json @@ -9,6 +9,12 @@ "null", "string" ] + }, + "type": { + "type": [ + "null", + "string" + ] } } },