ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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'
 

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 202 of file class.arFieldList.php.

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

◆ getAllowedConnectorFields()

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

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

Referenced by arField\getAttributesForConnector().

71  : array
72  {
73  return self::$allowed_connector_fields;
74  }
+ Here is the caller graph for this function:

◆ getAllowedDescriptionFields()

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

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

Referenced by arField\getAttributesForDescription().

79  : array
80  {
81  return self::$allowed_description_fields;
82  }
+ Here is the caller graph for this function:

◆ getArrayForConnector()

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

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

References getFields().

108  : array
109  {
110  $return = [];
111  foreach ($this->getFields() as $arField) {
112  $return[$arField->getName()] = $arField->getAttributesForConnector();
113  }
114 
115  return $return;
116  }
+ Here is the call graph for this function:

◆ getFieldByName()

arFieldList::getFieldByName ( string  $field_name)

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

References getFields().

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

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

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

References $fields.

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

228  : array
229  {
230  return $this->fields;
231  }
+ Here is the caller graph for this function:

◆ getInstance()

static arFieldList::getInstance ( ActiveRecord  $activeRecord)
static

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

References initRawFields().

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

84  : \arFieldList
85  {
86  $self = new self($activeRecord);
87  $self->initRawFields($activeRecord);
88  $self->initFields();
89 
90  return $self;
91  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initRawFields(ActiveRecord $ar)
+ 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 96 of file class.arFieldList.php.

References initRawFields().

Referenced by arFieldCache\storeFromStorage().

96  : \arFieldList
97  {
98  $self = new self($activeRecord);
99  $self->initRawFields($activeRecord);
100  $self->initFields();
101 
102  return $self;
103  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initRawFields(ActiveRecord $ar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPrimaryField()

arFieldList::getPrimaryField ( )
Returns
|mixed[]

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

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

241  : \arField|array
242  {
243  return $this->primary_field;
244  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
arField array $primary_field
+ Here is the caller graph for this function:

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )

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

References getPrimaryField().

162  : string
163  {
164  return $this->getPrimaryField()->getName();
165  }
+ Here is the call graph for this function:

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )
Returns
mixed[]

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

References $primary_fields.

273  : array
274  {
275  return $this->primary_fields;
276  }

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )

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

References getPrimaryField().

167  : string
168  {
169  return $this->getPrimaryField()->getFieldType();
170  }
+ Here is the call graph for this function:

◆ getRawFields()

arFieldList::getRawFields ( )
Returns
mixed[]

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

References $raw_fields.

Referenced by initFields().

257  : array
258  {
259  return $this->raw_fields;
260  }
+ Here is the caller graph for this function:

◆ initFields()

arFieldList::initFields ( )
protected

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

References getRawFields(), and setPrimaryField().

118  : void
119  {
120  foreach ($this->getRawFields() as $fieldname => $attributes) {
121  if (self::checkAttributes($attributes)) {
122  $arField = new arField();
123  $arField->loadFromArray($fieldname, $attributes);
124  $this->fields[] = $arField;
125  if ($arField->getPrimary()) {
126  $this->setPrimaryField($arField);
127  }
128  }
129  }
130  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setPrimaryField(\arField $arField)
+ Here is the call graph for this function:

◆ initRawFields()

arFieldList::initRawFields ( ActiveRecord  $ar)
protected

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

References setRawFields().

Referenced by getInstance(), and getInstanceFromStorage().

172  : void
173  {
174  $regex = "/[\t ]*\\* @(" . implode('|', self::$prefixes) . ")_([a-zA-Z0-9_]+)[\t ]+([a-zA-Z0-9_]+)/u";
175  $reflection = new ReflectionClass($ar);
176  $raw_fields = [];
177  foreach ($reflection->getProperties() as $property) {
178  if (in_array($property->getName(), self::$protected_names)) {
179  continue;
180  }
181  $properties_array = [];
182  $has_property = false;
183  foreach (explode("\n", $property->getDocComment()) as $line) {
184  if (preg_match($regex, $line, $matches)) {
185  $has_property = true;
186  $properties_array[$matches[2]] = $matches[3];
187  }
188  }
189  if ($has_property) {
190  $raw_fields[$property->getName()] = $properties_array;
191  }
192  }
193 
194  $this->setRawFields($raw_fields);
195  }
setRawFields(array $raw_fields)
+ 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 197 of file class.arFieldList.php.

197  : bool
198  {
199  return in_array($attribute_name, array_merge(self::$allowed_description_fields, [self::HAS_FIELD]), true);
200  }

◆ isField()

arFieldList::isField ( string  $field_name)

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

References getFields().

150  : bool
151  {
152  $is_field = false;
153  foreach ($this->getFields() as $arField) {
154  if ($arField->getName() === $field_name) {
155  $is_field = true;
156  }
157  }
158 
159  return $is_field;
160  }
+ Here is the call graph for this function:

◆ mapKey()

static arFieldList::mapKey ( string  $key)
static

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

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

59  : string
60  {
61  if (isset(self::$key_maps[$key])) {
62  return self::$key_maps[$key];
63  }
64 
65  return $key;
66  }
+ Here is the caller graph for this function:

◆ setFields()

arFieldList::setFields ( array  $fields)
Parameters

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

References $fields.

220  : void
221  {
222  $this->fields = $fields;
223  }

◆ setPrimaryField()

arFieldList::setPrimaryField ( \arField  $arField)

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

Referenced by initFields().

233  : void
234  {
235  $this->primary_field = $arField;
236  }
+ Here is the caller graph for this function:

◆ setPrimaryFields()

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

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

References $primary_fields.

265  : void
266  {
267  $this->primary_fields = $primary_fields;
268  }

◆ setRawFields()

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

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

References $raw_fields.

Referenced by initRawFields().

249  : void
250  {
251  $this->raw_fields = $raw_fields;
252  }
+ 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.

◆ $allowed_description_fields

array arFieldList::$allowed_description_fields
staticprotected
Initial value:
= [
'is_unique',
self::IS_PRIMARY,
self::IS_NOTNULL,
self::FIELDTYPE,
self::LENGTH,
self::SEQUENCE,
self::INDEX,
]

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

◆ $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'
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(), and setRawFields().

◆ FIELDTYPE

const arFieldList::FIELDTYPE = 'fieldtype'

◆ HAS_FIELD

const arFieldList::HAS_FIELD = 'has_field'

◆ 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.

Referenced by arConverter\returnAttributesForField().

◆ IS_PRIMARY

const arFieldList::IS_PRIMARY = 'is_primary'

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

Referenced by arConverter\returnAttributesForField().

◆ LENGTH

const arFieldList::LENGTH = 'length'

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

Referenced by arConverter\returnAttributesForField().

◆ 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: