src/Transformer/JsonSchemaForm/StringTransformer.php line 29
<?phpdeclare(strict_types=1);/*** Copyright (c) 2019 TECLA Consulting Group oü.* All rights reserved.** This unpublished material is proprietary to TECLA Consulting Group oü.* All rights reserved. The methods and* techniques described herein are considered trade secrets* and/or confidential. Reproduction or distribution, in whole* or in part, is forbidden except by express written permission* of TECLA Consulting Group oü.** @author Matúš Sýkorjak <matus@tecla.no>* @copyright 2019 TECLA Consulting Group oü*/namespace App\Transformer\JsonSchemaForm;use App\Util\JsonSchemaForm\JsonSchemaFormUtil;use Symfony\Component\Form\FormInterface;class StringTransformer extends AbstractTransformer{/*** {@inheritdoc}*/public function transform(FormInterface $form, array $extensions = [], string $widget = null): array{$schema = ['type' => 'string'];$schema = $this->addCommonSpecs($form, $schema, $widget, $extensions);$schema = $this->addMaxLength($form, $schema);$schema = $this->addMinLength($form, $schema);return $schema;}protected function addMaxLength(FormInterface $form, array $schema): array{if ($attr = $form->getConfig()->getOption('attr')) {if (true === isset($attr['maxlength'])) {$schema['maxLength'] = $attr['maxlength'];}}return $schema;}protected function addMinLength(FormInterface $form, array $schema): array{if ($attr = $form->getConfig()->getOption('attr')) {if (isset($attr['minlength'])) {$schema['minLength'] = $attr['minlength'];return $schema;}}if (null === $this->validatorGuesser) {return $schema;}$class = JsonSchemaFormUtil::findDataClass($form);if (null === $class) {return $schema;}$minLengthGuess = $this->validatorGuesser->guessMinLength($class, $form->getName());$minLength = null !== $minLengthGuess ? $minLengthGuess->getValue() : null;if ($minLength) {$schema['minLength'] = $minLength;}return $schema;}}