ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMMCustomItemFacade.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25
31{
33
34 protected string $action = '';
35
36 protected string $type = '';
37
38 protected bool $top_item = false;
39
43 public function __construct(IdentificationInterface $identification, Main $collector)
44 {
45 parent::__construct($identification, $collector);
46 $this->custom_item_storage = $this->getCustomStorage();
47 if ($this->custom_item_storage instanceof ilMMCustomItemStorage) {
48 if ($this->custom_item_storage->getType() !== '' && $this->custom_item_storage->getType() !== '0') {
49 $this->type = $this->custom_item_storage->getType();
50 }
51 $this->role_based_visibility = $this->custom_item_storage->hasRoleBasedVisibility();
52 if ($this->custom_item_storage->hasRoleBasedVisibility()) {
53 $this->global_role_ids = $this->custom_item_storage->getGlobalRoleIDs();
54 }
55 }
56 }
57
61 #[\Override]
62 public function update(): void
63 {
64 if ($this->isCustom()) {
65 $mm = $this->getCustomStorage();
66 if ($mm instanceof ilMMCustomItemStorage) {
67 if ($this->default_title === '-') {
68 $this->default_title = ilMMItemTranslationStorage::getDefaultTranslation($this->identification());
69 }
70 $mm->setDefaultTitle($this->default_title);
71 $mm->setType($this->getType());
72 $mm->setRoleBasedVisibility($this->role_based_visibility);
73 if ($this->role_based_visibility) {
74 $mm->setGlobalRoleIDs($this->global_role_ids);
75 }
76 $mm->update();
77 }
78 }
79 parent::update();
80 }
81
85 #[\Override]
86 public function delete(): void
87 {
88 if (!$this->isDeletable()) {
89 throw new LogicException("Non Custom items can't be deleted");
90 }
91
92 $cm = $this->getCustomStorage();
93 if ($cm instanceof ilMMCustomItemStorage) {
94 $cm->delete();
95 }
96 parent::delete();
97 }
98
99 private function getCustomStorage(): ?ilMMCustomItemStorage
100 {
101 $id = $this->raw_item->getProviderIdentification()->getInternalIdentifier();
103 $mm = ilMMCustomItemStorage::find($id);
104
105 return $mm;
106 }
107
111 #[\Override]
112 public function supportsRoleBasedVisibility(): bool
113 {
114 return true;
115 }
116
120 public function isCustom(): bool
121 {
122 return true;
123 }
124
128 public function isEditable(): bool
129 {
130 return true;
131 }
132
136 public function isDeletable(): bool
137 {
138 return true;
139 }
140
144 #[\Override]
145 public function getProviderNameForPresentation(): string
146 {
147 return "Custom";
148 }
149
153 public function setAction(string $action): void
154 {
155 $this->action = $action;
156 }
157
161 #[\Override]
162 public function getType(): string
163 {
164 return $this->type;
165 }
166
170 public function setType(string $type): void
171 {
172 $this->type = $type;
173 }
174
178 #[\Override]
179 public function isTopItem(): bool
180 {
181 if ($this->raw_item instanceof isItem) {
182 return parent::isTopItem();
183 }
184
185 return $this->top_item;
186 }
187
191 #[\Override]
192 public function setIsTopItm(bool $top_item): void
193 {
194 $this->top_item = $top_item;
195 }
196}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class MainMenuMainCollector This Collector will collect and then provide all available slates from th...
Class ilMMAbstractItemFacade.
Class ilMMCustomItemFacade.
setAction(string $action)
@inheritDoc
setIsTopItm(bool $top_item)
@inheritDoc
setType(string $type)
@inheritDoc
ilMMCustomItemStorage $custom_item_storage
__construct(IdentificationInterface $identification, Main $collector)
@inheritDoc
Class ilMMCustomItemStorage.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc