19 declare(strict_types=1);
35 protected \ILIAS\DI\Container
$DIC;
36 protected \ilLanguage
$lng;
44 $this->positionRepo =
$dic[
"repo.Positions"];
48 $this->
lng = $DIC->language();
50 $this->
ctrl = $DIC->ctrl();
51 $this->
ctrl->saveParameter($parent_gui,
'arid');
63 $lng = $DIC->language();
66 $te->setRequired(
true);
74 $m->setRenderOneForEmptyValue(
false);
84 $over_options += $this->positionRepo->getArray(
'id',
'title');
88 $available_scopes = [];
90 $txt = $lng->txt(
'scope_' . $scope);
95 $scopes->setOptions($available_scopes);
103 if (!$this->
object->getId()) {
117 self::F_TITLE => $this->
object->getTitle(),
118 self::F_DESCRIPTION => $this->
object->getDescription(),
119 self::F_AUTHORITIES => $this->
object->getAuthoritiesAsArray()
124 public function fillObject():
bool 130 $authorities = ($this->
getInput(self::F_AUTHORITIES) !=
'')
131 ? (array) $this->
getInput(self::F_AUTHORITIES)
134 if (count($authorities) == 0) {
135 $this->
object = $this->
object 136 ->withTitle($this->
getInput(self::F_TITLE))
137 ->withDescription($this->
getInput(self::F_DESCRIPTION))
138 ->withAuthorities([]);
145 $new_authorities = [];
146 foreach ($authorities as $authority) {
147 $id = ($authority[
"id"] ==
'') ? null : (
int) $authority[
"id"];
149 $new_authorities[] = $this->positionRepo->getAuthority(
$id)
150 ->withPositionId($this->
object->getId())
151 ->withScope((
int) $authority[
"scope"])
152 ->withOver((
int) $authority[
"over"]);
154 $this->
object = $this->
object 155 ->withTitle($this->
getInput(self::F_TITLE))
156 ->withDescription($this->
getInput(self::F_DESCRIPTION))
157 ->withAuthorities($new_authorities);
163 if ($this->fillObject() ===
false) {
167 $this->
object = $this->positionRepo->store($this->
object);
173 return $this->
lng->txt($key);
178 return $this->
lng->txt($key .
'_info');
This class represents a text area property in a property form.