ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMMCustomItemFacade.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
21 
27 {
29 
30  protected string $action = '';
31 
32  protected string $type = '';
33 
34  protected bool $top_item = false;
35 
40  {
41  parent::__construct($identification, $collector);
42  $this->custom_item_storage = $this->getCustomStorage();
43  if ($this->custom_item_storage instanceof ilMMCustomItemStorage) {
44  if ($this->custom_item_storage->getType()) {
45  $this->type = $this->custom_item_storage->getType();
46  }
47  $this->role_based_visibility = $this->custom_item_storage->hasRoleBasedVisibility();
48  if ($this->custom_item_storage->hasRoleBasedVisibility()) {
49  $this->global_role_ids = $this->custom_item_storage->getGlobalRoleIDs();
50  }
51  }
52  }
53 
57  public function update(): void
58  {
59  if ($this->isCustom()) {
60  $mm = $this->getCustomStorage();
61  if ($mm instanceof ilMMCustomItemStorage) {
62  if ($this->default_title === '-') {
63  $this->default_title = ilMMItemTranslationStorage::getDefaultTranslation($this->identification());
64  }
65  $mm->setDefaultTitle($this->default_title);
66  $mm->setType($this->getType());
67  $mm->setRoleBasedVisibility($this->role_based_visibility);
68  if ($this->role_based_visibility) {
69  $mm->setGlobalRoleIDs($this->global_role_ids);
70  }
71  $mm->update();
72  }
73  }
74  parent::update();
75  }
76 
80  public function delete(): void
81  {
82  if (!$this->isDeletable()) {
83  throw new LogicException("Non Custom items can't be deleted");
84  }
85 
86  $cm = $this->getCustomStorage();
87  if ($cm instanceof ilMMCustomItemStorage) {
88  $cm->delete();
89  }
90  parent::delete();
91  }
92 
93  private function getCustomStorage(): ?ilMMCustomItemStorage
94  {
95  $id = $this->raw_item->getProviderIdentification()->getInternalIdentifier();
97  $mm = ilMMCustomItemStorage::find($id);
98 
99  return $mm;
100  }
101 
105  public function supportsRoleBasedVisibility(): bool
106  {
107  return true;
108  }
109 
113  public function isCustom(): bool
114  {
115  return true;
116  }
117 
121  public function isEditable(): bool
122  {
123  return true;
124  }
125 
129  public function isDeletable(): bool
130  {
131  return true;
132  }
133 
137  public function getProviderNameForPresentation(): string
138  {
139  return "Custom";
140  }
141 
145  public function getStatus(): string
146  {
147  return "";
148  }
149 
153  public function setAction(string $action): void
154  {
155  $this->action = $action;
156  }
157 
161  public function getType(): string
162  {
163  return $this->type;
164  }
165 
169  public function setType(string $type): void
170  {
171  $this->type = $type;
172  }
173 
177  public function isTopItem(): bool
178  {
179  if ($this->raw_item instanceof \ILIAS\GlobalScreen\Scope\MainMenu\Factory\isItem) {
180  return parent::isTopItem();
181  }
182 
183  return $this->top_item;
184  }
185 
189  public function setIsTopItm(bool $top_item): void
190  {
191  $this->top_item = $top_item;
192  }
193 }
Class ilMMAbstractItemFacade.
ilMMCustomItemStorage $custom_item_storage
Class ChatMainBarProvider .
IdentificationInterface $identification
__construct(IdentificationInterface $identification, Main $collector)
Class ilMMCustomItemFacade.
__construct(Container $dic, ilPlugin $plugin)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23