ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilMMCustomItemFacade.php
Go to the documentation of this file.
1 <?php
18 declare(strict_types=1);
19 
23 
29 {
31 
32  protected string $action = '';
33 
34  protected string $type = '';
35 
36  protected bool $top_item = false;
37 
41  public function __construct(IdentificationInterface $identification, Main $collector)
42  {
43  parent::__construct($identification, $collector);
44  $this->custom_item_storage = $this->getCustomStorage();
45  if ($this->custom_item_storage instanceof ilMMCustomItemStorage) {
46  if ($this->custom_item_storage->getType() !== '' && $this->custom_item_storage->getType() !== '0') {
47  $this->type = $this->custom_item_storage->getType();
48  }
49  $this->role_based_visibility = $this->custom_item_storage->hasRoleBasedVisibility();
50  if ($this->custom_item_storage->hasRoleBasedVisibility()) {
51  $this->global_role_ids = $this->custom_item_storage->getGlobalRoleIDs();
52  }
53  }
54  }
55 
59  #[\Override]
60  public function update(): void
61  {
62  if ($this->isCustom()) {
63  $mm = $this->getCustomStorage();
64  if ($mm instanceof ilMMCustomItemStorage) {
65  if ($this->default_title === '-') {
66  $this->default_title = ilMMItemTranslationStorage::getDefaultTranslation($this->identification());
67  }
68  $mm->setDefaultTitle($this->default_title);
69  $mm->setType($this->getType());
70  $mm->setRoleBasedVisibility($this->role_based_visibility);
71  if ($this->role_based_visibility) {
72  $mm->setGlobalRoleIDs($this->global_role_ids);
73  }
74  $mm->update();
75  }
76  }
77  parent::update();
78  }
79 
83  #[\Override]
84  public function delete(): void
85  {
86  if (!$this->isDeletable()) {
87  throw new LogicException("Non Custom items can't be deleted");
88  }
89 
90  $cm = $this->getCustomStorage();
91  if ($cm instanceof ilMMCustomItemStorage) {
92  $cm->delete();
93  }
94  parent::delete();
95  }
96 
97  private function getCustomStorage(): ?ilMMCustomItemStorage
98  {
99  $id = $this->raw_item->getProviderIdentification()->getInternalIdentifier();
101  $mm = ilMMCustomItemStorage::find($id);
102 
103  return $mm;
104  }
105 
109  #[\Override]
110  public function supportsRoleBasedVisibility(): bool
111  {
112  return true;
113  }
114 
118  public function isCustom(): bool
119  {
120  return true;
121  }
122 
126  public function isEditable(): bool
127  {
128  return true;
129  }
130 
134  public function isDeletable(): bool
135  {
136  return true;
137  }
138 
142  #[\Override]
143  public function getProviderNameForPresentation(): string
144  {
145  return "Custom";
146  }
147 
151  #[\Override]
152  public function getStatus(): string
153  {
154  return "";
155  }
156 
160  public function setAction(string $action): void
161  {
162  $this->action = $action;
163  }
164 
168  #[\Override]
169  public function getType(): string
170  {
171  return $this->type;
172  }
173 
177  public function setType(string $type): void
178  {
179  $this->type = $type;
180  }
181 
185  #[\Override]
186  public function isTopItem(): bool
187  {
188  if ($this->raw_item instanceof isItem) {
189  return parent::isTopItem();
190  }
191 
192  return $this->top_item;
193  }
194 
198  #[\Override]
199  public function setIsTopItm(bool $top_item): void
200  {
201  $this->top_item = $top_item;
202  }
203 }
Class ilMMAbstractItemFacade.
ilMMCustomItemStorage $custom_item_storage
__construct(IdentificationInterface $identification, Main $collector)
Class ilMMCustomItemFacade.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)