ILIAS  release_8 Revision v8.24
class.ilADTSearchBridgeRange.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
9{
10 protected ilADT $adt_lower;
11 protected ilADT $adt_upper;
12
13 protected function setDefinition(ilADTDefinition $a_adt_def): void
14 {
15 if ($this->isValidADTDefinition($a_adt_def)) {
17 $this->adt_lower = $factory->getInstanceByDefinition($a_adt_def);
18 $this->adt_upper = $factory->getInstanceByDefinition($a_adt_def);
19 return;
20 }
21
22 throw new InvalidArgumentException('ilADTSearchBridge type mismatch.');
23 }
24
29 public function getLowerADT(): ?ilADT
30 {
31 return $this->adt_lower;
32 }
33
38 public function getUpperADT(): ?ilADT
39 {
40 return $this->adt_upper;
41 }
42
43 public function isNull(): bool
44 {
45 if (!$this->getLowerADT() instanceof ilADT || !$this->getUpperADT() instanceof ilADT) {
46 return false;
47 }
48 return ($this->getLowerADT()->isNull() && $this->getUpperADT()->isNull());
49 }
50
51 public function isValid(): bool
52 {
53 if (!$this->getLowerADT() instanceof ilADT || !$this->getUpperADT() instanceof ilADT) {
54 return false;
55 }
56 return ($this->getLowerADT()->isValid() && $this->getUpperADT()->isValid());
57 }
58
59 public function validate(): bool
60 {
61 if (!$this->getLowerADT() instanceof ilADT || !$this->getUpperADT() instanceof ilADT) {
62 return false;
63 }
64 if (!$this->isValid()) {
65 $tmp = [];
66 $mess = $this->getLowerADT()->getValidationErrors();
67 foreach ($mess as $error_code) {
68 $tmp[] = $this->getLowerADT()->translateErrorCode($error_code);
69 }
70 if ($tmp) {
71 $field = $this->getForm()->getItemByPostVar($this->addToElementId("lower"));
72 $field->setAlert(implode("<br />", $tmp));
73 }
74
75 $tmp = [];
76 $mess = $this->getUpperADT()->getValidationErrors();
77 foreach ($mess as $error_code) {
78 $tmp[] = $this->getUpperADT()->translateErrorCode($error_code);
79 }
80 if ($tmp) {
81 $field = $this->getForm()->getItemByPostVar($this->addToElementId("upper"));
82 $field->setAlert(implode("<br />", $tmp));
83 }
84 return false;
85 }
86 return true;
87 }
88}
ADT definition base class.
Class ilADTSearchBridgeRange.
setDefinition(ilADTDefinition $a_adt_def)
validate()
Validate current data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addToElementId(string $a_add)
Add sub-element.
isValidADTDefinition(ilADTDefinition $a_adt_def)
ADT base class.
Definition: class.ilADT.php:12
$factory
Definition: metadata.php:75