ILIAS  release_8 Revision v8.23
class.ilADTSearchBridgeSingle.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
9 {
10  protected ilADT $adt;
11 
12  protected function setDefinition(ilADTDefinition $a_adt_def): void
13  {
14  if ($this->isValidADTDefinition($a_adt_def)) {
15  $this->adt = ilADTFactory::getInstance()->getInstanceByDefinition($a_adt_def);
16  return;
17  }
18 
19  throw new InvalidArgumentException('ilADTSearchBridge type mismatch.');
20  }
21 
26  public function getADT(): ?ilADT
27  {
28  return $this->adt;
29  }
30 
31  public function isNull(): bool
32  {
33  return !$this->getADT() instanceof ilADT || $this->getADT()->isNull();
34  }
35 
36  public function isValid(): bool
37  {
38  return $this->getADT() instanceof ilADT && $this->getADT()->isValid();
39  }
40 
41  public function validate(): bool
42  {
43  if (!$this->getADT() instanceof ilADT) {
44  return false;
45  }
46  if (!$this->isValid()) {
47  $tmp = array();
48  $mess = $this->getADT()->getValidationErrors();
49  foreach ($mess as $error_code) {
50  $tmp[] = $this->getADT()->translateErrorCode($error_code);
51  }
52  $field = $this->getForm()->getItemByPostVar($this->getElementId());
53  $field->setAlert(implode("<br />", $tmp));
54 
55  return false;
56  }
57  return true;
58  }
59 }
isValidADTDefinition(ilADTDefinition $a_adt_def)
setDefinition(ilADTDefinition $a_adt_def)
ADT base class.
Definition: class.ilADT.php:11
Class ilADTSearchBridgeSingle.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ADT definition base class.