ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTMultiEnumDefinition.php
Go to the documentation of this file.
1<?php
2
4{
5 protected $options = []; // [array]
6 protected $numeric; // [bool]
7
8
9 // default
10
11 public function reset()
12 {
13 parent::reset();
14
15 $this->options = array();
16 $this->setNumeric(true);
17 }
18
19
20 // properties
21
22 public function getOptions()
23 {
24 return $this->options;
25 }
26
27 public function setOptions(array $a_values)
28 {
29 if ($this->isNumeric()) {
30 foreach (array_keys($a_values) as $key) {
31 if (!is_numeric($key)) {
32 throw new Exception("ilADTMultiEnum was expecting numeric option keys");
33 }
34 }
35 }
36
37 $this->options = $a_values;
38 }
39
40 public function isNumeric()
41 {
42 return $this->numeric;
43 }
44
45 public function setNumeric($a_value)
46 {
47 $this->numeric = $a_value;
48 }
49
50
51 // comparison
52
53 public function isComparableTo(ilADT $a_adt)
54 {
55 // has to be text-based
56 return ($a_adt instanceof ilADTMultiEnum);
57 }
58
59
60 // ADT instance
61
62 public function getADTInstance()
63 {
64 if ($this->isNumeric()) {
65 $class = "ilADTMultiEnumNumeric";
66 } else {
67 $class = "ilADTMultiEnumText";
68 }
69 include_once "Services/ADT/classes/Types/MultiEnum/class.ilADTMultiEnum.php";
70 include_once "Services/ADT/classes/Types/MultiEnum/class." . $class . ".php";
71 return new $class($this);
72 }
73}
An exception for terminatinating execution or to throw for unit testing.
ADT definition base class.
isComparableTo(ilADT $a_adt)
Check if given ADT is comparable to self.
ADT base class.
Definition: class.ilADT.php:12
$key
Definition: croninfo.php:18