ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilADTSearchBridgeSingle.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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 }
isValidADTDefinition(ilADTDefinition $a_adt_def)
setDefinition(ilADTDefinition $a_adt_def)
ADT base class.
Definition: class.ilADT.php:25
Class ilADTSearchBridgeSingle.
ADT search bridge base class.
ADT definition base class.