ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
AbstractBaseItem.php
Go to the documentation of this file.
2
7
13abstract class AbstractBaseItem implements isItem
14{
19 protected $renderer;
23 protected $position = 0;
27 protected $available_callable = true;
36
37
44 {
45 $this->provider_identification = $provider_identification;
46 $this->renderer = new BaseMetaBarItemRenderer();
47 }
48
49
53 public function getRenderer() : MetaBarItemRenderer
54 {
55 return $this->renderer;
56 }
57
58
63 {
65 }
66
67
71 public function withVisibilityCallable(callable $is_visible) : isItem
72 {
73 $clone = clone($this);
74 $clone->visiblility_callable = $is_visible;
75
76 return $clone;
77 }
78
79
83 public function isVisible() : bool
84 {
85 if (!$this->isAvailable()) {
86 return false;
87 }
88 if (is_callable($this->visiblility_callable)) {
90
91 $value = $callable();
92
93 return $value;
94 }
95
96 return true;
97 }
98
99
103 public function withAvailableCallable(callable $is_available) : isItem
104 {
105 $clone = clone($this);
106 $clone->available_callable = $is_available;
107
108 return $clone;
109 }
110
111
115 public function isAvailable() : bool
116 {
117 if (is_callable($this->available_callable)) {
118 $callable = $this->available_callable;
119
120 $value = $callable();
121
122 return $value;
123 }
124
125 return true;
126 }
127
128
132 public function getPosition() : int
133 {
134 return $this->position;
135 }
136
137
141 public function withPosition(int $position) : isItem
142 {
143 $clone = clone($this);
144 $clone->position = $position;
145
146 return $clone;
147 }
148}
An exception for terminatinating execution or to throw for unit testing.
__construct(IdentificationInterface $provider_identification)
AbstractBaseItem constructor.