ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected ilADT $adt;
27
28 protected function setDefinition(ilADTDefinition $a_adt_def): void
29 {
30 if ($this->isValidADTDefinition($a_adt_def)) {
31 $this->adt = ilADTFactory::getInstance()->getInstanceByDefinition($a_adt_def);
32 return;
33 }
34
35 throw new InvalidArgumentException('ilADTSearchBridge type mismatch.');
36 }
37
42 public function getADT(): ?ilADT
43 {
44 return $this->adt;
45 }
46
47 public function isNull(): bool
48 {
49 return !$this->getADT() instanceof ilADT || $this->getADT()->isNull();
50 }
51
52 public function isValid(): bool
53 {
54 return $this->getADT() instanceof ilADT && $this->getADT()->isValid();
55 }
56
57 public function validate(): bool
58 {
59 if (!$this->getADT() instanceof ilADT) {
60 return false;
61 }
62 if (!$this->isValid()) {
63 $tmp = array();
64 $mess = $this->getADT()->getValidationErrors();
65 foreach ($mess as $error_code) {
66 $tmp[] = $this->getADT()->translateErrorCode($error_code);
67 }
68 $field = $this->getForm()->getItemByPostVar($this->getElementId());
69 $field->setAlert(implode("<br />", $tmp));
70
71 return false;
72 }
73 return true;
74 }
75}
ADT definition base class.
Class ilADTSearchBridgeSingle.
setDefinition(ilADTDefinition $a_adt_def)
ADT search bridge base class.
isValidADTDefinition(ilADTDefinition $a_adt_def)
ADT base class.
Definition: class.ilADT.php:26