ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMMCustomItemFacade.php
Go to the documentation of this file.
1 <?php
2 
5 
11 {
12 
20  protected $action = '';
24  protected $type = '';
28  protected $top_item = false;
29 
34  {
35  parent::__construct($identification, $collector);
36  $this->custom_item_storage = $this->getCustomStorage();
37  if ($this->custom_item_storage instanceof ilMMCustomItemStorage) {
38  if ($this->custom_item_storage->getType()) {
39  $this->type = $this->custom_item_storage->getType();
40  }
41  $this->role_based_visibility = $this->custom_item_storage->hasRoleBasedVisibility();
42  if ($this->custom_item_storage->hasRoleBasedVisibility()) {
43  $this->global_role_ids = $this->custom_item_storage->getGlobalRoleIDs();
44  }
45  }
46  }
47 
51  public function update()
52  {
53  if ($this->isCustom()) {
54  $mm = $this->getCustomStorage();
55  if ($mm instanceof ilMMCustomItemStorage) {
56  $default_title = ilMMItemTranslationStorage::getDefaultTranslation($this->identification());
57  $mm->setDefaultTitle($default_title);
58  $mm->setType($this->getType());
59  $mm->setRoleBasedVisibility($this->role_based_visibility);
60  if ($this->role_based_visibility) {
61  $mm->setGlobalRoleIDs($this->global_role_ids);
62  }
63  $mm->update();
64  }
65  }
66  parent::update();
67  }
68 
72  public function delete()
73  {
74  if (!$this->isDeletable()) {
75  throw new LogicException("Non Custom items can't be deleted");
76  }
77 
78  $cm = $this->getCustomStorage();
79  if ($cm instanceof ilMMCustomItemStorage) {
80  $cm->delete();
81  }
82  parent::delete();
83  }
84 
88  private function getCustomStorage()
89  {
90  $id = $this->raw_item->getProviderIdentification()->getInternalIdentifier();
91  $mm = ilMMCustomItemStorage::find($id);
92 
93  return $mm;
94  }
95 
99  public function supportsRoleBasedVisibility() : bool
100  {
101  return true;
102  }
103 
107  public function isCustom() : bool
108  {
109  return true;
110  }
111 
115  public function isEditable() : bool
116  {
117  return true;
118  }
119 
123  public function isDeletable() : bool
124  {
125  return true;
126  }
127 
131  public function getProviderNameForPresentation() : string
132  {
133  return "Custom";
134  }
135 
139  public function getStatus() : string
140  {
141  return "";
142  }
143 
147  public function setAction(string $action)
148  {
149  $this->action = $action;
150  }
151 
155  public function getType() : string
156  {
157  return $this->type;
158  }
159 
163  public function setType(string $type)
164  {
165  $this->type = $type;
166  }
167 
171  public function isTopItem() : bool
172  {
173  if ($this->raw_item instanceof \ILIAS\GlobalScreen\Scope\MainMenu\Factory\isItem) {
174  return parent::isTopItem();
175  }
176 
177  return $this->top_item;
178  }
179 
183  public function setIsTopItm(bool $top_item)
184  {
185  $this->top_item = $top_item;
186  }
187 }
Class ilMMAbstractItemFacade.
static find($primary_key, array $add_constructor_args=array())
Class ChatMainBarProvider .
__construct(IdentificationInterface $identification, Main $collector)
Class ilMMCustomItemFacade.
__construct(Container $dic, ilPlugin $plugin)