ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 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.

Referenced by arField\getAttributesForConnector().

67  : array
68  {
69  return self::$allowed_connector_fields;
70  }
+ Here is the caller graph for this function:

◆ getAllowedDescriptionFields()

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

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

Referenced by arField\getAttributesForDescription().

75  : array
76  {
77  return self::$allowed_description_fields;
78  }
+ 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.

References getFields().

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

◆ getFieldByName()

arFieldList::getFieldByName ( string  $field_name)

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

References getFields(), and null.

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...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

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

References $fields.

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

224  : array
225  {
226  return $this->fields;
227  }
+ Here is the caller graph for this function:

◆ getInstance()

static arFieldList::getInstance ( ActiveRecord  $activeRecord)
static

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

References initRawFields().

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

80  : \arFieldList
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)
+ 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.

References initRawFields().

Referenced by arFieldCache\storeFromStorage().

92  : \arFieldList
93  {
94  $self = new self($activeRecord);
95  $self->initRawFields($activeRecord);
96  $self->initFields();
97 
98  return $self;
99  }
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 237 of file class.arFieldList.php.

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

237  : \arField|array
238  {
239  return $this->primary_field;
240  }
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 158 of file class.arFieldList.php.

References getPrimaryField().

158  : string
159  {
160  return $this->getPrimaryField()->getName();
161  }
+ Here is the call graph for this function:

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )
Returns
mixed[]

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

References $primary_fields.

269  : array
270  {
271  return $this->primary_fields;
272  }

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )

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

References getPrimaryField().

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

◆ getRawFields()

arFieldList::getRawFields ( )
Returns
mixed[]

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

References $raw_fields.

Referenced by initFields().

253  : array
254  {
255  return $this->raw_fields;
256  }
+ Here is the caller graph for this function:

◆ initFields()

arFieldList::initFields ( )
protected

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

References getRawFields(), and setPrimaryField().

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

References setRawFields().

Referenced by getInstance(), and getInstanceFromStorage().

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 
190  $this->setRawFields($raw_fields);
191  }
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 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.

References getFields().

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  }
+ 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  return self::$key_maps[$key] ?? $key;
62  }
+ Here is the caller graph for this function:

◆ setFields()

arFieldList::setFields ( array  $fields)
Parameters

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

References $fields.

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

◆ setPrimaryField()

arFieldList::setPrimaryField ( \arField  $arField)

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

Referenced by initFields().

229  : void
230  {
231  $this->primary_field = $arField;
232  }
+ 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.

References $primary_fields.

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

◆ setRawFields()

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

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

References $raw_fields.

Referenced by initRawFields().

245  : void
246  {
247  $this->raw_fields = $raw_fields;
248  }
+ 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: