ILIAS  release_8 Revision v8.24
ilADTGroup Class Reference
+ Inheritance diagram for ilADTGroup:
+ Collaboration diagram for ilADTGroup:

Public Member Functions

 __clone ()
 
 reset ()
 Init property defaults. More...
 
 hasElement (string $a_name)
 
 getElement (string $a_name)
 
 getElements ()
 
 equals (ilADT $a_adt)
 Check if given ADT equals self. More...
 
 isLarger (ilADT $a_adt)
 Check if given ADT is larger than self. More...
 
 isSmaller (ilADT $a_adt)
 Check if given ADT is smaller than self. More...
 
 isNull ()
 Is currently null. More...
 
 getValidationErrorsByElements ()
 
 getValidationErrors ()
 @inheritcoc More...
 
 isValid ()
 
 translateErrorCode (string $a_code)
 @inheritcoc More...
 
 getCheckSum ()
 Get unique checksum. More...
 
 exportStdClass ()
 Export value as stdClass. More...
 
 importStdClass (?stdClass $a_std)
 Import value from stdClass. More...
 
- Public Member Functions inherited from ilADT
 __construct (ilADTDefinition $a_def)
 
 getType ()
 Get type (from class/instance) More...
 
 reset ()
 Init property defaults. More...
 
 getCopyOfDefinition ()
 Get copy of definition. More...
 
 equals (ilADT $a_adt)
 Check if given ADT equals self. More...
 
 isLarger (ilADT $a_adt)
 Check if given ADT is larger than self. More...
 
 isLargerOrEqual (ilADT $a_adt)
 
 isSmaller (ilADT $a_adt)
 Check if given ADT is smaller than self. More...
 
 isSmallerOrEqual (ilADT $a_adt)
 Check if given ADT is smaller or equal than self. More...
 
 isInbetween (ilADT $a_adt_from, ilADT $a_adt_to)
 Check if self is inbetween given ADTs (exclusive) More...
 
 isInbetweenOrEqual (ilADT $a_adt_from, ilADT $a_adt_to)
 Check if self is inbetween given ADTs (inclusive) More...
 
 isNull ()
 Is currently null. More...
 
 isValid ()
 
 getValidationErrors ()
 Get all validation error codes. More...
 
 translateErrorCode (string $a_code)
 Translate error-code to human-readable message. More...
 
 getCheckSum ()
 Get unique checksum. More...
 
 exportStdClass ()
 Export value as stdClass. More...
 
 importStdClass (?stdClass $a_std)
 Import value from stdClass. More...
 

Protected Member Functions

 isValidDefinition (ilADTDefinition $a_def)
 Check if definition is valid for ADT. More...
 
 setDefinition (ilADTDefinition $a_def)
 Set definition. More...
 
 addElement (string $a_name, ilADTDefinition $a_def)
 
 addElementValidationError (string $a_element_id, string $a_error_code)
 
- Protected Member Functions inherited from ilADT
 isValidDefinition (ilADTDefinition $a_def)
 Check if definition is valid for ADT. More...
 
 setDefinition (ilADTDefinition $a_def)
 Set definition. More...
 
 getDefinition ()
 Get definition. More...
 
 addValidationError (string $a_error_code)
 

Protected Attributes

array $elements = []
 
- Protected Attributes inherited from ilADT
ilADTDefinition $definition
 
ilLanguage $lng
 
array $validation_errors = []
 

Additional Inherited Members

- Data Fields inherited from ilADT
const ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED = "adt1"
 
const ADT_VALIDATION_ERROR_MAX_LENGTH = "adt2"
 
const ADT_VALIDATION_ERROR_MAX_SIZE = "adt3"
 
const ADT_VALIDATION_ERROR_MIN = "adt4"
 
const ADT_VALIDATION_ERROR_MAX = "adt5"
 
const ADT_VALIDATION_DATE = "adt6"
 
const ADT_VALIDATION_ERROR_INVALID_NODE = 'adt7'
 

Detailed Description

Definition at line 5 of file class.ilADTGroup.php.

Member Function Documentation

◆ __clone()

ilADTGroup::__clone ( )

Definition at line 9 of file class.ilADTGroup.php.

10 {
11 if (is_array($this->elements)) {
12 foreach ($this->elements as $id => $element) {
13 $this->elements[$id] = clone $element;
14 }
15 }
16 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

◆ addElement()

ilADTGroup::addElement ( string  $a_name,
ilADTDefinition  $a_def 
)
protected

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

46 : void
47 {
48 $this->elements[$a_name] = ilADTFactory::getInstance()->getInstanceByDefinition($a_def);
49 }

References ilADTFactory\getInstance().

Referenced by setDefinition().

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

◆ addElementValidationError()

ilADTGroup::addElementValidationError ( string  $a_element_id,
string  $a_error_code 
)
protected

Definition at line 107 of file class.ilADTGroup.php.

107 : void
108 {
109 $this->validation_errors[$a_error_code] = $a_element_id;
110 }

Referenced by isValid().

+ Here is the caller graph for this function:

◆ equals()

ilADTGroup::equals ( ilADT  $a_adt)

Check if given ADT equals self.

Parameters
ilADT$a_adt
Returns
bool|null

Reimplemented from ilADT.

Definition at line 69 of file class.ilADTGroup.php.

69 : ?bool
70 {
71 if ($this->getDefinition()->isComparableTo($a_adt)) {
72 return ($this->getCheckSum() == $a_adt->getCheckSum());
73 }
74 return null;
75 }
getCheckSum()
Get unique checksum.
getCheckSum()
Get unique checksum.
getDefinition()
Get definition.
Definition: class.ilADT.php:92

References ilADT\getCheckSum(), getCheckSum(), and ilADT\getDefinition().

+ Here is the call graph for this function:

◆ exportStdClass()

ilADTGroup::exportStdClass ( )

Export value as stdClass.

Returns
stdClass | null

Reimplemented from ilADT.

Definition at line 155 of file class.ilADTGroup.php.

155 : ?stdClass
156 {
157 $obj = new stdClass();
158 foreach ($this->getElements() as $id => $element) {
159 $obj->$id = $element->exportStdClass();
160 }
161 return $obj;
162 }

References $id, and getElements().

+ Here is the call graph for this function:

◆ getCheckSum()

ilADTGroup::getCheckSum ( )

Get unique checksum.

Returns
string | null

Reimplemented from ilADT.

Definition at line 143 of file class.ilADTGroup.php.

143 : ?string
144 {
145 if (!$this->isNull()) {
146 $tmp = [];
147 foreach ($this->getElements() as $element) {
148 $tmp[] = $element->getCheckSum();
149 }
150 return md5(implode(",", $tmp));
151 }
152 return null;
153 }
isNull()
Is currently null.

References getElements(), and isNull().

Referenced by equals().

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

◆ getElement()

ilADTGroup::getElement ( string  $a_name)

Definition at line 56 of file class.ilADTGroup.php.

56 : ?ilADT
57 {
58 if ($this->hasElement($a_name)) {
59 return $this->elements[$a_name];
60 }
61 return null;
62 }
hasElement(string $a_name)
ADT base class.
Definition: class.ilADT.php:12

References hasElement().

Referenced by translateErrorCode().

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

◆ getElements()

ilADTGroup::getElements ( )

Definition at line 64 of file class.ilADTGroup.php.

64 : array
65 {
66 return $this->elements;
67 }

References $elements.

Referenced by exportStdClass(), getCheckSum(), importStdClass(), isNull(), isValid(), reset(), and setDefinition().

+ Here is the caller graph for this function:

◆ getValidationErrors()

ilADTGroup::getValidationErrors ( )

@inheritcoc

Reimplemented from ilADT.

Definition at line 102 of file class.ilADTGroup.php.

102 : array
103 {
104 return array_keys($this->validation_errors);
105 }

◆ getValidationErrorsByElements()

ilADTGroup::getValidationErrorsByElements ( )

Definition at line 94 of file class.ilADTGroup.php.

94 : array
95 {
97 }
array $validation_errors
Definition: class.ilADT.php:17

References ilADT\$validation_errors.

◆ hasElement()

ilADTGroup::hasElement ( string  $a_name)

Definition at line 51 of file class.ilADTGroup.php.

51 : bool
52 {
53 return array_key_exists($a_name, $this->elements);
54 }

Referenced by getElement().

+ Here is the caller graph for this function:

◆ importStdClass()

ilADTGroup::importStdClass ( ?stdClass  $a_std)

Import value from stdClass.

Parameters
stdClass  |  null$a_std

Reimplemented from ilADT.

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

164 : void
165 {
166 if (is_object($a_std)) {
167 foreach ($this->getElements() as $id => $element) {
168 $element->importStdClass($a_std->$id);
169 }
170 }
171 }

References $id, and getElements().

+ Here is the call graph for this function:

◆ isLarger()

ilADTGroup::isLarger ( ilADT  $a_adt)

Check if given ADT is larger than self.

Parameters
ilADT$a_adt
Returns
bool

Reimplemented from ilADT.

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

77 : ?bool
78 {
79 return null;
80 }

◆ isNull()

ilADTGroup::isNull ( )

Is currently null.

Returns
bool | null

Reimplemented from ilADT.

Definition at line 89 of file class.ilADTGroup.php.

89 : bool
90 {
91 return !count($this->getElements());
92 }

References getElements().

Referenced by getCheckSum(), and isValid().

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

◆ isSmaller()

ilADTGroup::isSmaller ( ilADT  $a_adt)

Check if given ADT is smaller than self.

Parameters
ilADT$a_adt
Returns
bool | null

Reimplemented from ilADT.

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

82 : ?bool
83 {
84 return null;
85 }

◆ isValid()

ilADTGroup::isValid ( )

Reimplemented from ilADT.

Definition at line 112 of file class.ilADTGroup.php.

112 : bool
113 {
114 $valid = parent::isValid();
115 if (!$this->isNull()) {
116 foreach ($this->getElements() as $element_id => $element) {
117 if (!$element->isValid()) {
118 foreach ($element->getValidationErrors() as $error) {
119 $this->addElementValidationError((string) $element_id, $error);
120 }
121 $valid = false;
122 }
123 }
124 }
125 return $valid;
126 }
addElementValidationError(string $a_element_id, string $a_error_code)
$valid

References $valid, addElementValidationError(), getElements(), and isNull().

+ Here is the call graph for this function:

◆ isValidDefinition()

ilADTGroup::isValidDefinition ( ilADTDefinition  $a_def)
protected

Check if definition is valid for ADT.

Parameters
ilADTDefinition$a_def
Returns
bool

Reimplemented from ilADT.

Definition at line 18 of file class.ilADTGroup.php.

18 : bool
19 {
20 return ($a_def instanceof ilADTGroupDefinition);
21 }

◆ reset()

ilADTGroup::reset ( )

Init property defaults.

Reimplemented from ilADT.

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

34 : void
35 {
36 parent::reset();
37
38 $elements = $this->getElements();
39 if (is_array($elements)) {
40 foreach ($elements as $element) {
41 $element->reset();
42 }
43 }
44 }

References $elements, and getElements().

+ Here is the call graph for this function:

◆ setDefinition()

ilADTGroup::setDefinition ( ilADTDefinition  $a_def)
protected

Set definition.

Parameters
ilADTDefinition$a_def
Exceptions
ilException

Reimplemented from ilADT.

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

23 : void
24 {
25 parent::setDefinition($a_def);
26
27 $this->elements = array();
28
29 foreach ($this->getDefinition()->getElements() as $name => $def) {
30 $this->addElement((string) $name, $def);
31 }
32 }
addElement(string $a_name, ilADTDefinition $a_def)
if($format !==null) $name
Definition: metadata.php:247

References $name, addElement(), ilADT\getDefinition(), and getElements().

+ Here is the call graph for this function:

◆ translateErrorCode()

ilADTGroup::translateErrorCode ( string  $a_code)

@inheritcoc

Reimplemented from ilADT.

Definition at line 131 of file class.ilADTGroup.php.

131 : string
132 {
133 if (isset($this->validation_errors[$a_code])) {
134 $element_id = $this->validation_errors[$a_code];
135 $element = $this->getElement($element_id);
136 if ($element) {
137 return $element->translateErrorCode($a_code);
138 }
139 }
140 return parent::translateErrorCode($a_code);
141 }
getElement(string $a_name)

References getElement().

+ Here is the call graph for this function:

Field Documentation

◆ $elements

array ilADTGroup::$elements = []
protected

Definition at line 7 of file class.ilADTGroup.php.

Referenced by getElements(), and reset().


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