ILIAS  release_8 Revision v8.24
class.ilADTFactory.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
9{
10 public const TYPE_LOCALIZED_TEXT = 'LocalizedText';
11
12 protected static ?ilADTFactory $instance = null;
13
14 public static function getInstance(): ilADTFactory
15 {
16 if (self::$instance === null) {
17 self::$instance = new self();
18 }
19 return self::$instance;
20 }
21
26 public function getValidTypes(): array
27 {
28 return array(
29 "Float",
30 "Integer",
31 "Location",
32 "Text",
33 "Boolean",
34 "MultiText",
35 "Date",
36 "DateTime",
37 "Enum",
38 "MultiEnum",
39 "Group",
40 'ExternalLink',
41 'InternalLink',
42 self::TYPE_LOCALIZED_TEXT
43 );
44 }
45
46 public function isValidType(string $a_type): bool
47 {
48 return in_array($a_type, $this->getValidTypes());
49 }
50
51 public function initTypeClass(string $a_type, string $a_class = null): string
52 {
53 $class = '';
54 if ($this->isValidType($a_type)) {
55 $class = "ilADT" . $a_type . $a_class;
56 return $class;
57 }
58 throw new InvalidArgumentException("ilADTFactory unknown type: " . $a_type);
59 }
60
67 public function getDefinitionInstanceByType(string $a_type): ilADTDefinition
68 {
69 $class = $this->initTypeClass($a_type, "Definition");
70 return new $class();
71 }
72
80 {
81 if (!method_exists($a_def, "getADTInstance")) {
82 $class = $this->initTypeClass($a_def->getType());
83 return new $class($a_def);
84 } else {
85 return $a_def->getADTInstance();
86 }
87 }
88
96 {
97 $class = $this->initTypeClass($a_adt->getType(), "FormBridge");
98 return new $class($a_adt);
99 }
100
108 {
109 $class = $this->initTypeClass($a_adt->getType(), "DBBridge");
110 return new $class($a_adt);
111 }
112
120 {
121 $class = $this->initTypeClass($a_adt->getType(), "PresentationBridge");
122 return new $class($a_adt);
123 }
124
134 ilADTDefinition $a_adt_def,
135 bool $a_range = true,
136 bool $a_multi = true
138 if ($a_range) {
139 try {
140 $class = $this->initTypeClass($a_adt_def->getType(), "SearchBridgeRange");
141 if (class_exists($class)) {
142 return new $class($a_adt_def);
143 }
144 } catch (Exception $e) {
145 }
146 }
147
148 // multi enum search (single) == enum search (multi)
149 if (!$a_multi &&
150 $a_adt_def->getType() == "MultiEnum") {
151 $class = $this->initTypeClass("Enum", "SearchBridgeMulti");
152 return new $class($a_adt_def);
153 }
154
155 if ($a_multi) {
156 try {
157 if ($a_adt_def->getType() == 'MultiEnum') {
158 $class = $this->initTypeClass('Enum', 'SearchBridgeMulti');
159 return new $class($a_adt_def);
160 }
161 $class = $this->initTypeClass($a_adt_def->getType(), "SearchBridgeMulti");
162 return new $class($a_adt_def);
163 } catch (Exception $e) {
164 }
165 }
166 $class = $this->initTypeClass($a_adt_def->getType(), "SearchBridgeSingle");
167 return new $class($a_adt_def);
168 }
169
177 {
178 $class = $this->initTypeClass($a_adt->getType(), "ActiveRecordBridge");
179 return new $class($a_adt);
180 }
181
182
183 //
184 // active records
185 //
186
192 public static function getActiveRecordInstance(ilADTGroupDBBridge $a_properties): ilADTActiveRecord
193 {
194 return new ilADTActiveRecord($a_properties);
195 }
196
200 public static function initActiveRecordByType(): void
201 {
202 }
203
208 {
209 self::initActiveRecordByType();
210 return new ilADTActiveRecordByType($a_properties);
211 }
212}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ADT Active Record helper class This class expects a valid primary for all actions!
ADT DB bridge base class.
ADT definition base class.
getType()
Get type (from class/instance)
Class ilADTFactory.
static getActiveRecordByTypeInstance(ilADTDBBridge $a_properties)
Get active record by type instance.
getSearchBridgeForDefinitionInstance(ilADTDefinition $a_adt_def, bool $a_range=true, bool $a_multi=true)
Get search bridge instance for ADT definition.
getDBBridgeForInstance(ilADT $a_adt)
Get DB bridge instance for ADT.
getValidTypes()
Get all ADT types.
static getActiveRecordInstance(ilADTGroupDBBridge $a_properties)
Get active record instance.
getPresentationBridgeForInstance(ilADT $a_adt)
Get presentation bridge instance for ADT.
getFormBridgeForInstance(ilADT $a_adt)
Get form bridge instance for ADT.
isValidType(string $a_type)
initTypeClass(string $a_type, string $a_class=null)
getDefinitionInstanceByType(string $a_type)
Get instance of ADT definition.
static ilADTFactory $instance
static initActiveRecordByType()
Init active record by type.
getActiveRecordBridgeForInstance(ilADT $a_adt)
Get active record instance for ADT.
getInstanceByDefinition(ilADTDefinition $a_def)
Get instance of ADT.
ADT form bridge base class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ADT base class.
Definition: class.ilADT.php:12
getType()
Get type (from class/instance)
Definition: class.ilADT.php:50
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20