19declare(strict_types=1);
41 $this->db =
$DIC->database();
42 $this->
lng = $DIC->language();
75 return $this->properties->isValid();
86 public function __call($a_method, $a_value)
88 $type = substr($a_method, 0, 3);
91 $parsed = strtolower(preg_replace(
"/([A-Z])/",
" $1", substr($a_method, 3)));
92 $parsed = str_replace(
" ",
"_", trim($parsed));
93 if (!$this->properties->hasElement($parsed)) {
94 throw new Exception(
"ilADTObject unknown property " . $parsed);
96 return $this->properties->getElement($parsed);
99 throw new Exception(
"ilADTObject unknown type: " . $type);
140 throw new Exception(
"ilADTBasedObject no primary");
144 $adt_db = $factory->getDBBridgeForInstance($this->properties);
152 return $factory->getActiveRecordInstance($adt_db);
184 $this->db_errors[
$e->getColumn()][] =
$e->getCode();
208 $this->db_errors[
$e->getColumn()][] =
$e->getCode();
220 public function delete():
bool
248 foreach ($a_codes as $code) {
251 $res[] =
"Unknown ADT error code " . $code;
267 foreach ($this->
getProperties()->getValidationErrorsByElements() as $error_code => $element_id) {
268 $tmp[] = $element_id .
" [validation]: " . $this->
getProperties()->translateErrorCode($error_code);
271 foreach ($this->
getDBErrors() as $element_id => $codes) {
276 return get_class($this) . $delimiter . implode($delimiter, $tmp);
ADT Active Record helper class This class expects a valid primary for all actions!
ADT based-object base class Currently "mixed" with ActiveRecord-pattern, could be splitted.
initActiveRecordInstance()
Init active record helper for current table, primary and properties.
__construct()
Constructor Tries to read record from DB, in accordance to current ILIAS behaviour.
getAllTranslatedErrors(string $delimiter="\n")
Get translated error codes (DB, Validation)
initProperties()
Init properties (aka set ADT definition)
__call($a_method, $a_value)
Get property magic method ("get<PropertyName>()") Setters are type-specific and cannot be magic.
translateDBErrorCodes(array $a_codes)
Translate DB error codes.
createPrimaryKeyb()
Create new primary key, e.g.
getDBErrors()
Get DB errors.
hasPrimary()
Check if currently has primary.
parsePrimary(array $a_args)
Parse incoming primary key.
update()
Update record (only if valid)
create()
Create record (only if valid)
initDBBridge(ilADTDBBridge $a_adt_db)
Init (properties) DB bridge.
getProperties()
Get all properties.
ADT DB bridge base class.