ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
arFieldList Class Reference

Class arFieldList. More...

+ Collaboration diagram for arFieldList:

Public Member Functions

 __construct (ActiveRecord $ar)
 arFieldList constructor. More...
 
 getArrayForConnector ()
 
 getFieldByName (string $field_name)
 
 isField (string $field_name)
 
 getPrimaryFieldName ()
 
 getPrimaryFieldType ()
 
 setFields (array $fields)
 
 getFields ()
 
 setPrimaryField (\arField $primary_field)
 
 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 $ar)
 
static getInstanceFromStorage (\ActiveRecord $ar)
 

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

 $primary_field
 
array $primary_fields = array()
 
array $raw_fields = array()
 
array $fields = array()
 
ActiveRecord $ar
 

Static Protected Attributes

static array $prefixes = array('db', 'con')
 
static array $protected_names = array('arConnector', 'arFieldList')
 
static array $allowed_description_fields
 
static array $allowed_connector_fields
 
static array $key_maps
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

arFieldList::__construct ( ActiveRecord  $ar)

arFieldList constructor.

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

References $ar.

63  {
64  $this->ar = $ar;
65  }
ActiveRecord $ar

Member Function Documentation

◆ checkAttributes()

static arFieldList::checkAttributes ( array  $attributes)
staticprotected

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

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

◆ getAllowedConnectorFields()

static arFieldList::getAllowedConnectorFields ( )
static

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

Referenced by arField\getAttributesForConnector().

77  : array
78  {
79  return self::$allowed_connector_fields;
80  }
+ Here is the caller graph for this function:

◆ getAllowedDescriptionFields()

static arFieldList::getAllowedDescriptionFields ( )
static

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

Referenced by arField\getAttributesForDescription().

82  : array
83  {
84  return self::$allowed_description_fields;
85  }
+ Here is the caller graph for this function:

◆ getArrayForConnector()

arFieldList::getArrayForConnector ( )

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

References getFields().

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

◆ getFieldByName()

arFieldList::getFieldByName ( string  $field_name)

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

References getFields().

133  : ?arField
134  {
135  $field = null;
136  static $field_map;
137  $field_key = $this->ar->getConnectorContainerName() . '.' . $field_name;
138  if (is_array($field_map) && array_key_exists($field_key, $field_map)) {
139  return $field_map[$field_key];
140  }
141  foreach ($this->getFields() as $field) {
142  if ($field->getName() === $field_name) {
143  $field_map[$field_key] = $field;
144 
145  return $field;
146  }
147  }
148  return null;
149  }
Class arField.
+ Here is the call graph for this function:

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

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

References $fields.

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

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

◆ getInstance()

static arFieldList::getInstance ( ActiveRecord  $ar)
static

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

References $ar, and initRawFields().

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

87  : \arFieldList
88  {
89  $arFieldList = new self($ar);
90  $arFieldList->initRawFields($ar);
91  $arFieldList->initFields();
92 
93  return $arFieldList;
94  }
ActiveRecord $ar
Class arFieldList.
initRawFields(ActiveRecord $ar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstanceFromStorage()

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

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

References $ar, and initRawFields().

Referenced by arFieldCache\storeFromStorage().

99  : \arFieldList
100  {
101  $arFieldList = new self($ar);
102  $arFieldList->initRawFields($ar);
103  $arFieldList->initFields();
104 
105  return $arFieldList;
106  }
ActiveRecord $ar
Class arFieldList.
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 243 of file class.arFieldList.php.

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

244  {
245  return $this->primary_field;
246  }
+ Here is the caller graph for this function:

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )

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

References getPrimaryField().

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

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )

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

References $primary_fields.

266  : array
267  {
268  return $this->primary_fields;
269  }

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )

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

References getPrimaryField().

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

◆ getRawFields()

arFieldList::getRawFields ( )

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

References $raw_fields.

Referenced by initFields().

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

◆ initFields()

arFieldList::initFields ( )
protected

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

References $attributes, fields, getRawFields(), and setPrimaryField().

119  : void
120  {
121  foreach ($this->getRawFields() as $fieldname => $attributes) {
122  if (self::checkAttributes($attributes)) {
123  $arField = new arField();
124  $arField->loadFromArray($fieldname, $attributes);
125  $this->fields[] = $arField;
126  if ($arField->getPrimary()) {
127  $this->setPrimaryField($arField);
128  }
129  }
130  }
131  }
Class arField.
$attributes
Definition: metadata.php:248
$errors fields
Definition: imgupload.php:67
setPrimaryField(\arField $primary_field)
+ Here is the call graph for this function:

◆ initRawFields()

arFieldList::initRawFields ( ActiveRecord  $ar)
protected

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

References setRawFields().

Referenced by getInstance(), and getInstanceFromStorage().

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

199  : bool
200  {
201  return in_array($attribute_name, array_merge(self::$allowed_description_fields, array(self::HAS_FIELD)), true);
202  }

◆ isField()

arFieldList::isField ( string  $field_name)

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

References getFields().

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

◆ mapKey()

static arFieldList::mapKey ( string  $key)
static

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

References ILIAS\LTI\ToolProvider\$key.

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

67  : string
68  {
69  if (isset(self::$key_maps[$key])) {
70  return self::$key_maps[$key];
71  }
72 
73  return $key;
74  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ setFields()

arFieldList::setFields ( array  $fields)
Parameters

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

References $fields, and fields.

222  : void
223  {
224  $this->fields = $fields;
225  }
$errors fields
Definition: imgupload.php:67

◆ setPrimaryField()

arFieldList::setPrimaryField ( \arField  $primary_field)

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

References $primary_field.

Referenced by initFields().

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

◆ setPrimaryFields()

arFieldList::setPrimaryFields ( array  $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 251 of file class.arFieldList.php.

References $raw_fields.

Referenced by initRawFields().

251  : void
252  {
253  $this->raw_fields = $raw_fields;
254  }
+ Here is the caller graph for this function:

Field Documentation

◆ $allowed_connector_fields

array arFieldList::$allowed_connector_fields
staticprotected
Initial value:
= array(
self::IS_NOTNULL,
self::FIELDTYPE,
self::LENGTH,
)

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

◆ $allowed_description_fields

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

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

◆ $ar

ActiveRecord arFieldList::$ar
protected

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

Referenced by __construct(), getInstance(), and getInstanceFromStorage().

◆ $fields

array arFieldList::$fields = array()
protected

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

Referenced by getFields(), and setFields().

◆ $key_maps

array arFieldList::$key_maps
staticprotected
Initial value:
= array(
self::FIELDTYPE => 'type',
self::IS_NOTNULL => 'notnull',
)

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

◆ $prefixes

array arFieldList::$prefixes = array('db', 'con')
staticprotected

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

◆ $primary_field

arFieldList::$primary_field
protected

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

Referenced by getPrimaryField(), and setPrimaryField().

◆ $primary_fields

array arFieldList::$primary_fields = array()
protected

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

Referenced by getPrimaryFields(), and setPrimaryFields().

◆ $protected_names

array arFieldList::$protected_names = array('arConnector', 'arFieldList')
staticprotected

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

◆ $raw_fields

array arFieldList::$raw_fields = array()
protected

Definition at line 51 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 29 of file class.arFieldList.php.

◆ IS_NOTNULL

const arFieldList::IS_NOTNULL = 'is_notnull'

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

Referenced by arConverter\returnAttributesForField().

◆ IS_PRIMARY

const arFieldList::IS_PRIMARY = 'is_primary'

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

Referenced by arConverter\returnAttributesForField().

◆ LENGTH

const arFieldList::LENGTH = 'length'

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

Referenced by arConverter\returnAttributesForField().

◆ SEQUENCE

const arFieldList::SEQUENCE = 'sequence'

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


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