ILIAS  release_8 Revision v8.24
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.

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

References $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

References $attributes.

◆ getAllowedConnectorFields()

static arFieldList::getAllowedConnectorFields ( )
static

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

77 : array
78 {
80 }
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

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

82 : array
83 {
85 }
static array $allowed_description_fields

References $allowed_description_fields.

Referenced by arField\getAttributesForDescription().

+ Here is the caller graph for this function:

◆ getArrayForConnector()

arFieldList::getArrayForConnector ( )

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

109 : array
110 {
111 $return = array();
112 foreach ($this->getFields() as $field) {
113 $return[$field->getName()] = $field->getAttributesForConnector();
114 }
115
116 return $return;
117 }

References getFields().

+ Here is the call graph for this function:

◆ getFieldByName()

arFieldList::getFieldByName ( string  $field_name)

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

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.

References getFields().

+ Here is the call graph for this function:

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

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

230 : array
231 {
232 return $this->fields;
233 }

References $fields.

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

+ Here is the caller graph for this function:

◆ getInstance()

static arFieldList::getInstance ( ActiveRecord  $ar)
static

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

88 {
89 $arFieldList = new self($ar);
90 $arFieldList->initRawFields($ar);
91 $arFieldList->initFields();
92
93 return $arFieldList;
94 }
Class arFieldList.
initRawFields(ActiveRecord $ar)

References $ar, and initRawFields().

Referenced by arFieldCache\store().

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

100 {
101 $arFieldList = new self($ar);
102 $arFieldList->initRawFields($ar);
103 $arFieldList->initFields();
104
105 return $arFieldList;
106 }

References $ar, and 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 243 of file class.arFieldList.php.

244 {
246 }

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

+ Here is the caller graph for this function:

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )

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

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

References getPrimaryField().

+ Here is the call graph for this function:

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )

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

266 : array
267 {
269 }

References $primary_fields.

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )

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

169 : string
170 {
171 return $this->getPrimaryField()->getFieldType();
172 }

References getPrimaryField().

+ Here is the call graph for this function:

◆ getRawFields()

arFieldList::getRawFields ( )

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

256 : array
257 {
258 return $this->raw_fields;
259 }

References $raw_fields.

Referenced by initFields().

+ Here is the caller graph for this function:

◆ initFields()

arFieldList::initFields ( )
protected

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

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 }
setPrimaryField(\arField $primary_field)
$errors fields
Definition: imgupload.php:67

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

+ Here is the call graph for this function:

◆ initRawFields()

arFieldList::initRawFields ( ActiveRecord  $ar)
protected

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

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
197 }
setRawFields(array $raw_fields)

References $ar, $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 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.

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 }

References getFields().

+ Here is the call graph for this function:

◆ mapKey()

static arFieldList::mapKey ( string  $key)
static

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

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

References ILIAS\LTI\ToolProvider\$key.

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

222 : void
223 {
224 $this->fields = $fields;
225 }

References $fields, and fields.

◆ setPrimaryField()

arFieldList::setPrimaryField ( \arField  $primary_field)

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

235 : void
236 {
237 $this->primary_field = $primary_field;
238 }

References $primary_field.

Referenced by initFields().

+ Here is the caller graph for this function:

◆ setPrimaryFields()

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

251 : void
252 {
253 $this->raw_fields = $raw_fields;
254 }

References $raw_fields.

Referenced by initRawFields().

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

Referenced by getAllowedConnectorFields().

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

Referenced by getAllowedDescriptionFields().

◆ $ar

ActiveRecord arFieldList::$ar
protected

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

◆ FIELDTYPE

const arFieldList::FIELDTYPE = 'fieldtype'

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

Referenced by arField\isAllowedAttribute().

◆ HAS_FIELD

const arFieldList::HAS_FIELD = 'has_field'

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

Referenced by arField\isAllowedAttribute().

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

◆ IS_PRIMARY

const arFieldList::IS_PRIMARY = 'is_primary'

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

◆ LENGTH

const arFieldList::LENGTH = 'length'

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

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