| @@ 31-57 (lines=27) @@ | ||
| 28 | /** |
|
| 29 | * @package Limoncello\Flute |
|
| 30 | */ |
|
| 31 | class FormValidatorFactory implements FormValidatorFactoryInterface |
|
| 32 | { |
|
| 33 | use HasContainerTrait, HasValidationFormatterTrait; |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @param ContainerInterface $container |
|
| 37 | */ |
|
| 38 | public function __construct(ContainerInterface $container) |
|
| 39 | { |
|
| 40 | $this->setContainer($container); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @inheritdoc |
|
| 45 | */ |
|
| 46 | public function createValidator(string $class): FormValidatorInterface |
|
| 47 | { |
|
| 48 | /** @var SettingsProviderInterface $settingsProvider */ |
|
| 49 | $settingsProvider = $this->getContainer()->get(SettingsProviderInterface::class); |
|
| 50 | $settings = $settingsProvider->get(S::class); |
|
| 51 | $ruleSetsData = $settings[S::KEY_ATTRIBUTE_VALIDATION_RULE_SETS_DATA]; |
|
| 52 | $formatter = $this->createValidationFormatter(); |
|
| 53 | $validator = new Validator($class, $ruleSetsData, $this->getContainer(), $formatter); |
|
| 54 | ||
| 55 | return $validator; |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||
| @@ 30-56 (lines=27) @@ | ||
| 27 | /** |
|
| 28 | * @package Limoncello\Flute |
|
| 29 | */ |
|
| 30 | class JsonApiValidatorFactory implements JsonApiValidatorFactoryInterface |
|
| 31 | { |
|
| 32 | use HasContainerTrait; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param ContainerInterface $container |
|
| 36 | */ |
|
| 37 | public function __construct(ContainerInterface $container) |
|
| 38 | { |
|
| 39 | $this->setContainer($container); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @inheritdoc |
|
| 44 | */ |
|
| 45 | public function createValidator(string $class): JsonApiValidatorInterface |
|
| 46 | { |
|
| 47 | /** @var SettingsProviderInterface $settingsProvider */ |
|
| 48 | $settingsProvider = $this->getContainer()->get(SettingsProviderInterface::class); |
|
| 49 | $settings = $settingsProvider->get(FluteSettings::class); |
|
| 50 | $ruleSetsData = $settings[FluteSettings::KEY_JSON_VALIDATION_RULE_SETS_DATA]; |
|
| 51 | ||
| 52 | $validator = new Validator($class, $ruleSetsData, $this->getContainer()); |
|
| 53 | ||
| 54 | return $validator; |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||