‪TYPO3CMS  10.4
Property.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 
25 {
29  private ‪$name;
30 
34  private ‪$definition;
35 
39  private ‪$characteristics;
40 
45  public function ‪__construct(string ‪$name, array ‪$definition)
46  {
47  $this->name = ‪$name;
48  $this->characteristics = new ‪PropertyCharacteristics(‪$definition['propertyCharacteristicsBit']);
49  unset(‪$definition['propertyCharacteristicsBit']);
50 
51  $defaults = [
52  'c' => null, // cascade
53  'd' => null, // defaultValue
54  't' => null, // type
55  'e' => null, // elementType
56  'v' => [], // validators
57  ];
58 
59  foreach ($defaults as $key => $defaultValue) {
60  if (!isset(‪$definition[$key])) {
61  ‪$definition[$key] = $defaultValue;
62  }
63  }
64 
65  $this->definition = ‪$definition;
66  }
67 
71  public function ‪getName(): string
72  {
73  return ‪$this->name;
74  }
75 
83  public function ‪getType(): ?string
84  {
85  return $this->definition['t'];
86  }
87 
98  public function ‪getElementType(): ?string
99  {
100  return $this->definition['e'];
101  }
102 
106  public function ‪isPublic(): bool
107  {
108  return $this->characteristics->get(‪PropertyCharacteristics::VISIBILITY_PUBLIC);
109  }
110 
114  public function ‪isProtected(): bool
115  {
116  return $this->characteristics->get(‪PropertyCharacteristics::VISIBILITY_PROTECTED);
117  }
118 
122  public function ‪isPrivate(): bool
123  {
124  return $this->characteristics->get(‪PropertyCharacteristics::VISIBILITY_PRIVATE);
125  }
126 
130  public function ‪isLazy(): bool
131  {
132  return $this->characteristics->get(‪PropertyCharacteristics::ANNOTATED_LAZY);
133  }
134 
138  public function ‪isTransient(): bool
139  {
140  return $this->characteristics->get(‪PropertyCharacteristics::ANNOTATED_TRANSIENT);
141  }
142 
146  public function ‪isInjectProperty(): bool
147  {
148  return $this->characteristics->get(‪PropertyCharacteristics::ANNOTATED_INJECT);
149  }
150 
154  public function ‪getValidators(): array
155  {
156  return $this->definition['v'];
157  }
158 
162  public function ‪getDefaultValue()
163  {
164  return $this->definition['d'];
165  }
166 
170  public function ‪getCascadeValue(): ?string
171  {
172  return $this->definition['c'];
173  }
174 }
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\ANNOTATED_INJECT
‪const ANNOTATED_INJECT
Definition: PropertyCharacteristics.php:33
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isProtected
‪bool isProtected()
Definition: Property.php:111
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getType
‪string null getType()
Definition: Property.php:80
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isLazy
‪bool isLazy()
Definition: Property.php:127
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\$definition
‪array $definition
Definition: Property.php:32
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isTransient
‪bool isTransient()
Definition: Property.php:135
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getDefaultValue
‪mixed getDefaultValue()
Definition: Property.php:159
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\__construct
‪__construct(string $name, array $definition)
Definition: Property.php:42
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\ANNOTATED_LAZY
‪const ANNOTATED_LAZY
Definition: PropertyCharacteristics.php:31
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\$name
‪string $name
Definition: Property.php:28
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\VISIBILITY_PUBLIC
‪const VISIBILITY_PUBLIC
Definition: PropertyCharacteristics.php:29
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\VISIBILITY_PRIVATE
‪const VISIBILITY_PRIVATE
Definition: PropertyCharacteristics.php:27
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isPublic
‪bool isPublic()
Definition: Property.php:103
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isInjectProperty
‪bool isInjectProperty()
Definition: Property.php:143
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getValidators
‪array getValidators()
Definition: Property.php:151
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\$characteristics
‪PropertyCharacteristics $characteristics
Definition: Property.php:36
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics
Definition: PropertyCharacteristics.php:26
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property
Definition: Property.php:25
‪TYPO3\CMS\Extbase\Reflection\ClassSchema
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getName
‪string getName()
Definition: Property.php:68
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isPrivate
‪bool isPrivate()
Definition: Property.php:119
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getCascadeValue
‪string null getCascadeValue()
Definition: Property.php:167
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getElementType
‪string null getElementType()
Definition: Property.php:95
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\ANNOTATED_TRANSIENT
‪const ANNOTATED_TRANSIENT
Definition: PropertyCharacteristics.php:32
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\VISIBILITY_PROTECTED
‪const VISIBILITY_PROTECTED
Definition: PropertyCharacteristics.php:28