ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
arFieldList Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for arFieldList:

Public Member Functions

 __construct (protected ActiveRecord $activeRecord)
 arFieldList constructor. More...
 
 getArrayForConnector ()
 
 getFieldByName (string $field_name)
 
 isField (string $field_name)
 
 getPrimaryFieldName ()
 
 getPrimaryFieldType ()
 
 setFields (array $fields)
 
 getFields ()
 
 setPrimaryField (\arField $arField)
 
 getPrimaryField ()
 
 setRawFields (array $raw_fields)
 
 getRawFields ()
 
 setPrimaryFields (array $primary_fields)
 
 getPrimaryFields ()
 

Static Public Member Functions

static mapKey (string $key)
 
static getAllowedConnectorFields ()
 
static getAllowedDescriptionFields ()
 
static getInstance (ActiveRecord $activeRecord)
 
static getInstanceFromStorage (\ActiveRecord $activeRecord)
 

Data Fields

const HAS_FIELD = 'has_field'
 
const IS_PRIMARY = 'is_primary'
 
const IS_NOTNULL = 'is_notnull'
 
const FIELDTYPE = 'fieldtype'
 
const LENGTH = 'length'
 
const SEQUENCE = 'sequence'
 
const INDEX = 'index'
 

Protected Member Functions

 initFields ()
 
 initRawFields (ActiveRecord $ar)
 

Static Protected Member Functions

static isAllowedAttribute (string $attribute_name)
 
static checkAttributes (array $attributes)
 

Protected Attributes

arField array $primary_field
 
array $primary_fields = []
 
array $raw_fields = []
 
array $fields = []
 

Static Protected Attributes

static array $prefixes = ['db', 'con']
 
static array $protected_names = ['arConnector', 'arFieldList']
 
static array $allowed_description_fields
 
static array $allowed_connector_fields = [self::IS_NOTNULL, self::FIELDTYPE, self::LENGTH]
 
static array $key_maps = [self::FIELDTYPE => 'type', self::IS_NOTNULL => 'notnull']
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class arFieldList

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
2.0.7

Definition at line 24 of file class.arFieldList.php.

Constructor & Destructor Documentation

◆ __construct()

arFieldList::__construct ( protected ActiveRecord  $activeRecord)

arFieldList constructor.

Definition at line 55 of file class.arFieldList.php.

56 {
57 }

Member Function Documentation

◆ checkAttributes()

static arFieldList::checkAttributes ( array  $attributes)
staticprotected

Definition at line 198 of file class.arFieldList.php.

198 : bool
199 {
200 if (isset($attributes[self::HAS_FIELD]) && $attributes[self::HAS_FIELD] === 'true') {
201 foreach (array_keys($attributes) as $atr) {
202 if (!self::isAllowedAttribute($atr)) {
203 return false;
204 }
205 }
206 } else {
207 return false;
208 }
209
210 return true;
211 }

◆ getAllowedConnectorFields()

static arFieldList::getAllowedConnectorFields ( )
static
Returns
mixed[]

Definition at line 67 of file class.arFieldList.php.

67 : array
68 {
70 }
static array $allowed_connector_fields

References $allowed_connector_fields.

Referenced by arField\getAttributesForConnector().

+ Here is the caller graph for this function:

◆ getAllowedDescriptionFields()

static arFieldList::getAllowedDescriptionFields ( )
static
Returns
mixed[]

Definition at line 75 of file class.arFieldList.php.

75 : array
76 {
78 }
static array $allowed_description_fields

References $allowed_description_fields.

Referenced by arField\getAttributesForDescription().

+ Here is the caller graph for this function:

◆ getArrayForConnector()

arFieldList::getArrayForConnector ( )
Returns
array<string, array<int|string, mixed>>

Definition at line 104 of file class.arFieldList.php.

104 : array
105 {
106 $return = [];
107 foreach ($this->getFields() as $arField) {
108 $return[$arField->getName()] = $arField->getAttributesForConnector();
109 }
110
111 return $return;
112 }

References getFields().

+ Here is the call graph for this function:

◆ getFieldByName()

arFieldList::getFieldByName ( string  $field_name)

Definition at line 128 of file class.arFieldList.php.

128 : ?arField
129 {
130 $field = null;
131 static $field_map;
132 $field_key = $this->activeRecord->getConnectorContainerName() . '.' . $field_name;
133 if (is_array($field_map) && array_key_exists($field_key, $field_map)) {
134 return $field_map[$field_key];
135 }
136 foreach ($this->getFields() as $field) {
137 if ($field->getName() === $field_name) {
138 $field_map[$field_key] = $field;
139
140 return $field;
141 }
142 }
143 return null;
144 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References getFields().

+ Here is the call graph for this function:

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

Definition at line 224 of file class.arFieldList.php.

224 : array
225 {
226 return $this->fields;
227 }

References $fields.

Referenced by getArrayForConnector(), getFieldByName(), and isField().

+ Here is the caller graph for this function:

◆ getInstance()

static arFieldList::getInstance ( ActiveRecord  $activeRecord)
static

Definition at line 80 of file class.arFieldList.php.

81 {
82 $self = new self($activeRecord);
83 $self->initRawFields($activeRecord);
84 $self->initFields();
85
86 return $self;
87 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initRawFields(ActiveRecord $ar)

References initRawFields().

Referenced by arFieldCache\store(), and ilServicesActiveRecordFieldTest\testFieldList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstanceFromStorage()

static arFieldList::getInstanceFromStorage ( \ActiveRecord  $activeRecord)
static
Deprecated:

Definition at line 92 of file class.arFieldList.php.

93 {
94 $self = new self($activeRecord);
95 $self->initRawFields($activeRecord);
96 $self->initFields();
97
98 return $self;
99 }

References initRawFields().

Referenced by arFieldCache\storeFromStorage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPrimaryField()

arFieldList::getPrimaryField ( )
Returns
\arField|mixed[]

Definition at line 237 of file class.arFieldList.php.

237 : \arField|array
238 {
240 }
arField array $primary_field

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

+ Here is the caller graph for this function:

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )

Definition at line 158 of file class.arFieldList.php.

158 : string
159 {
160 return $this->getPrimaryField()->getName();
161 }

References getPrimaryField().

+ Here is the call graph for this function:

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )
Returns
mixed[]

Definition at line 269 of file class.arFieldList.php.

269 : array
270 {
272 }

References $primary_fields.

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )

Definition at line 163 of file class.arFieldList.php.

163 : string
164 {
165 return $this->getPrimaryField()->getFieldType();
166 }

References getPrimaryField().

+ Here is the call graph for this function:

◆ getRawFields()

arFieldList::getRawFields ( )
Returns
mixed[]

Definition at line 253 of file class.arFieldList.php.

253 : array
254 {
255 return $this->raw_fields;
256 }

References $raw_fields.

Referenced by initFields().

+ Here is the caller graph for this function:

◆ initFields()

arFieldList::initFields ( )
protected

Definition at line 114 of file class.arFieldList.php.

114 : void
115 {
116 foreach ($this->getRawFields() as $fieldname => $attributes) {
117 if (self::checkAttributes($attributes)) {
118 $arField = new arField();
119 $arField->loadFromArray($fieldname, $attributes);
120 $this->fields[] = $arField;
121 if ($arField->getPrimary()) {
122 $this->setPrimaryField($arField);
123 }
124 }
125 }
126 }
setPrimaryField(\arField $arField)

References getRawFields(), and setPrimaryField().

+ Here is the call graph for this function:

◆ initRawFields()

arFieldList::initRawFields ( ActiveRecord  $ar)
protected

Definition at line 168 of file class.arFieldList.php.

168 : void
169 {
170 $regex = "/[\t ]*\\* @(" . implode('|', self::$prefixes) . ")_([a-zA-Z0-9_]+)[\t ]+([a-zA-Z0-9_]+)/u";
171 $reflection = new ReflectionClass($ar);
172 $raw_fields = [];
173 foreach ($reflection->getProperties() as $property) {
174 if (in_array($property->getName(), self::$protected_names)) {
175 continue;
176 }
177 $properties_array = [];
178 $has_property = false;
179 foreach (explode("\n", $property->getDocComment()) as $line) {
180 if (preg_match($regex, $line, $matches)) {
181 $has_property = true;
182 $properties_array[$matches[2]] = $matches[3];
183 }
184 }
185 if ($has_property) {
186 $raw_fields[$property->getName()] = $properties_array;
187 }
188 }
189
191 }
setRawFields(array $raw_fields)

References $raw_fields, and setRawFields().

Referenced by getInstance(), and getInstanceFromStorage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAllowedAttribute()

static arFieldList::isAllowedAttribute ( string  $attribute_name)
staticprotected

Definition at line 193 of file class.arFieldList.php.

193 : bool
194 {
195 return in_array($attribute_name, array_merge(self::$allowed_description_fields, [self::HAS_FIELD]), true);
196 }

◆ isField()

arFieldList::isField ( string  $field_name)

Definition at line 146 of file class.arFieldList.php.

146 : bool
147 {
148 $is_field = false;
149 foreach ($this->getFields() as $arField) {
150 if ($arField->getName() === $field_name) {
151 $is_field = true;
152 }
153 }
154
155 return $is_field;
156 }

References getFields().

+ Here is the call graph for this function:

◆ mapKey()

static arFieldList::mapKey ( string  $key)
static

Definition at line 59 of file class.arFieldList.php.

59 : string
60 {
61 return self::$key_maps[$key] ?? $key;
62 }

Referenced by arBuilder\generateDBUpdateForInstallation(), arField\getAttributesForConnector(), and arField\getAttributesForDescription().

+ Here is the caller graph for this function:

◆ setFields()

arFieldList::setFields ( array  $fields)
Parameters
\arField[]$fields

Definition at line 216 of file class.arFieldList.php.

216 : void
217 {
218 $this->fields = $fields;
219 }

References $fields.

◆ setPrimaryField()

arFieldList::setPrimaryField ( \arField  $arField)

Definition at line 229 of file class.arFieldList.php.

229 : void
230 {
231 $this->primary_field = $arField;
232 }

Referenced by initFields().

+ Here is the caller graph for this function:

◆ setPrimaryFields()

arFieldList::setPrimaryFields ( array  $primary_fields)
Parameters
mixed[]$primary_fields

Definition at line 261 of file class.arFieldList.php.

261 : void
262 {
263 $this->primary_fields = $primary_fields;
264 }

References $primary_fields.

◆ setRawFields()

arFieldList::setRawFields ( array  $raw_fields)
Parameters
mixed[]$raw_fields

Definition at line 245 of file class.arFieldList.php.

245 : void
246 {
247 $this->raw_fields = $raw_fields;
248 }

References $raw_fields.

Referenced by initRawFields().

+ Here is the caller graph for this function:

Field Documentation

◆ $allowed_connector_fields

array arFieldList::$allowed_connector_fields = [self::IS_NOTNULL, self::FIELDTYPE, self::LENGTH]
staticprotected

Definition at line 45 of file class.arFieldList.php.

Referenced by getAllowedConnectorFields().

◆ $allowed_description_fields

array arFieldList::$allowed_description_fields
staticprotected

◆ $fields

array arFieldList::$fields = []
protected

Definition at line 49 of file class.arFieldList.php.

Referenced by getFields(), and setFields().

◆ $key_maps

array arFieldList::$key_maps = [self::FIELDTYPE => 'type', self::IS_NOTNULL => 'notnull']
staticprotected

Definition at line 50 of file class.arFieldList.php.

◆ $prefixes

array arFieldList::$prefixes = ['db', 'con']
staticprotected

Definition at line 33 of file class.arFieldList.php.

◆ $primary_field

arField array arFieldList::$primary_field
protected

Definition at line 46 of file class.arFieldList.php.

Referenced by getPrimaryField().

◆ $primary_fields

array arFieldList::$primary_fields = []
protected

Definition at line 47 of file class.arFieldList.php.

Referenced by getPrimaryFields(), and setPrimaryFields().

◆ $protected_names

array arFieldList::$protected_names = ['arConnector', 'arFieldList']
staticprotected

Definition at line 34 of file class.arFieldList.php.

◆ $raw_fields

array arFieldList::$raw_fields = []
protected

Definition at line 48 of file class.arFieldList.php.

Referenced by getRawFields(), initRawFields(), and setRawFields().

◆ FIELDTYPE

const arFieldList::FIELDTYPE = 'fieldtype'

Definition at line 29 of file class.arFieldList.php.

Referenced by arField\isAllowedAttribute().

◆ HAS_FIELD

const arFieldList::HAS_FIELD = 'has_field'

Definition at line 26 of file class.arFieldList.php.

Referenced by arField\isAllowedAttribute().

◆ INDEX

const arFieldList::INDEX = 'index'

Definition at line 32 of file class.arFieldList.php.

◆ IS_NOTNULL

const arFieldList::IS_NOTNULL = 'is_notnull'

Definition at line 28 of file class.arFieldList.php.

◆ IS_PRIMARY

const arFieldList::IS_PRIMARY = 'is_primary'

Definition at line 27 of file class.arFieldList.php.

◆ LENGTH

const arFieldList::LENGTH = 'length'

Definition at line 30 of file class.arFieldList.php.

◆ SEQUENCE

const arFieldList::SEQUENCE = 'sequence'

Definition at line 31 of file class.arFieldList.php.


The documentation for this class was generated from the following file: