ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTSearchBridgeRange.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected ilADT $adt_lower;
27 protected ilADT $adt_upper;
28
29 protected function setDefinition(ilADTDefinition $a_adt_def): void
30 {
31 if ($this->isValidADTDefinition($a_adt_def)) {
32 $factory = ilADTFactory::getInstance();
33 $this->adt_lower = $factory->getInstanceByDefinition($a_adt_def);
34 $this->adt_upper = $factory->getInstanceByDefinition($a_adt_def);
35 return;
36 }
37
38 throw new InvalidArgumentException('ilADTSearchBridge type mismatch.');
39 }
40
45 public function getLowerADT(): ?ilADT
46 {
47 return $this->adt_lower;
48 }
49
54 public function getUpperADT(): ?ilADT
55 {
56 return $this->adt_upper;
57 }
58
59 public function isNull(): bool
60 {
61 if (!$this->getLowerADT() instanceof ilADT || !$this->getUpperADT() instanceof ilADT) {
62 return false;
63 }
64 return ($this->getLowerADT()->isNull() && $this->getUpperADT()->isNull());
65 }
66
67 public function isValid(): bool
68 {
69 if (!$this->getLowerADT() instanceof ilADT || !$this->getUpperADT() instanceof ilADT) {
70 return false;
71 }
72 return ($this->getLowerADT()->isValid() && $this->getUpperADT()->isValid());
73 }
74
75 public function validate(): bool
76 {
77 if (!$this->getLowerADT() instanceof ilADT || !$this->getUpperADT() instanceof ilADT) {
78 return false;
79 }
80 if (!$this->isValid()) {
81 $tmp = [];
82 $mess = $this->getLowerADT()->getValidationErrors();
83 foreach ($mess as $error_code) {
84 $tmp[] = $this->getLowerADT()->translateErrorCode($error_code);
85 }
86 if ($tmp) {
87 $field = $this->getForm()->getItemByPostVar($this->addToElementId("lower"));
88 $field->setAlert(implode("<br />", $tmp));
89 }
90
91 $tmp = [];
92 $mess = $this->getUpperADT()->getValidationErrors();
93 foreach ($mess as $error_code) {
94 $tmp[] = $this->getUpperADT()->translateErrorCode($error_code);
95 }
96 if ($tmp) {
97 $field = $this->getForm()->getItemByPostVar($this->addToElementId("upper"));
98 $field->setAlert(implode("<br />", $tmp));
99 }
100 return false;
101 }
102 return true;
103 }
104}
ADT definition base class.
Class ilADTSearchBridgeRange.
setDefinition(ilADTDefinition $a_adt_def)
validate()
Validate current data.
ADT search bridge base class.
addToElementId(string $a_add)
Add sub-element.
isValidADTDefinition(ilADTDefinition $a_adt_def)
ADT base class.
Definition: class.ilADT.php:26