‪TYPO3CMS  ‪main
Validate.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\Common\Annotations\Annotation\Required;
21 
26 #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
28 {
32  public string ‪$validator = '';
33 
34  public string ‪$param = '';
35 
39  public array ‪$options = [];
40 
44  public function ‪__construct(array $values)
45  {
46  if (isset($values['value'])) {
47  $this->validator = $values['value'];
48  }
49 
50  if (isset($values['validator'])) {
51  $this->validator = $values['validator'];
52  }
53 
54  if (isset($values['options'])) {
55  $this->options = $values['options'];
56  }
57 
58  if (isset($values['param'])) {
59  $this->param = $values['param'];
60  }
61  }
62 
63  public function ‪__toString(): string
64  {
65  $strings = [];
66 
67  if ($this->param !== '') {
68  $strings[] = ‪$this->param;
69  }
70 
71  $strings[] = ‪$this->validator;
72 
73  if (count($this->options) > 0) {
74  $validatorOptionsStrings = [];
75  foreach ($this->options as $optionKey => $optionValue) {
76  $validatorOptionsStrings[] = $optionKey . '=' . $optionValue;
77  }
78 
79  $strings[] = '(' . implode(', ', $validatorOptionsStrings) . ')';
80  }
81 
82  return trim(implode(' ', $strings));
83  }
84 }
‪TYPO3\CMS\Extbase\Annotation\Validate\$param
‪string $param
Definition: Validate.php:34
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:18
‪TYPO3\CMS\Extbase\Annotation\Validate\__construct
‪__construct(array $values)
Definition: Validate.php:44
‪TYPO3\CMS\Extbase\Annotation\Validate\__toString
‪__toString()
Definition: Validate.php:63
‪TYPO3\CMS\Extbase\Annotation\Validate\$options
‪array $options
Definition: Validate.php:39
‪TYPO3\CMS\Extbase\Annotation\Validate\$validator
‪string $validator
Definition: Validate.php:32
‪TYPO3\CMS\Extbase\Annotation\Validate
Definition: Validate.php:28