20 declare(strict_types=1);
34 protected \ILIAS\DI\Container
$DIC;
35 protected \ilLanguage
$lng;
45 $this->positionRepo =
$dic[
"repo.Positions"];
47 $this->parent_gui = $parent_gui;
48 $this->
object = $object;
49 $this->
lng = $DIC->language();
50 $this->
ctrl = $DIC->ctrl();
52 $action_cmd = $object->
getId() > 0 ? BaseCommands::CMD_UPDATE : BaseCommands::CMD_CREATE;
53 $form_action = $parent_gui->getSinglePosLinkTarget($action_cmd, $object->
getId());
66 $lng = $DIC->language();
69 $te->setRequired(
true);
77 $m->setRenderOneForEmptyValue(
false);
87 $over_options += $this->positionRepo->getArray(
'id',
'title');
91 $available_scopes = [];
93 $txt = $lng->txt(
'scope_' . $scope);
98 $scopes->setOptions($available_scopes);
106 if (!$this->
object->getId()) {
120 self::F_TITLE => $this->
object->getTitle(),
121 self::F_DESCRIPTION => $this->
object->getDescription(),
122 self::F_AUTHORITIES => $this->
object->getAuthoritiesAsArray()
127 public function fillObject():
bool 133 $authorities = ($this->
getInput(self::F_AUTHORITIES) !=
'')
134 ? (array) $this->
getInput(self::F_AUTHORITIES)
137 if (count($authorities) == 0) {
138 $this->
object = $this->
object 139 ->withTitle($this->
getInput(self::F_TITLE))
140 ->withDescription($this->
getInput(self::F_DESCRIPTION))
141 ->withAuthorities([]);
148 $new_authorities = [];
149 foreach ($authorities as $authority) {
150 $id = ($authority[
"id"] ==
'') ? null : (
int) $authority[
"id"];
152 $new_authorities[] = $this->positionRepo->getAuthority(
$id)
153 ->withPositionId($this->
object->getId())
154 ->withScope((
int) $authority[
"scope"])
155 ->withOver((
int) $authority[
"over"]);
157 $this->
object = $this->
object 158 ->withTitle($this->
getInput(self::F_TITLE))
159 ->withDescription($this->
getInput(self::F_DESCRIPTION))
160 ->withAuthorities($new_authorities);
166 if ($this->fillObject() ===
false) {
170 $this->
object = $this->positionRepo->store($this->
object);
174 private function txt(
string $key): string
176 return $this->
lng->txt($key);
181 return $this->
lng->txt($key .
'_info');
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.