ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMMItemRepository Class Reference

Class ilMMItemRepository. More...

+ Inheritance diagram for ilMMItemRepository:
+ Collaboration diagram for ilMMItemRepository:

Public Member Functions

 __construct ()
 ilMMItemRepository constructor. More...
 
 getContainerKey ()
 
 isForced ()
 
 clearCache ()
 
 getSingleItem (IdentificationInterface $identification)
 
 getSingleItemFromFilter (IdentificationInterface $identification)
 
 resolveIdentificationFromString (string $identification_string)
 
 repository ()
 
 getTopItems ()
 
 getSubItemsForTable ()
 
 flushLostItems ()
 
 hasLostItems ()
 
 getItemFacade (IdentificationInterface $identification=null)
 
 getItemFacadeForIdentificationString (string $identification)
 
 getPossibleParentsForFormAndTable ()
 
 getPossibleSubItemTypesWithInformation ()
 
 getPossibleTopItemTypesWithInformation (bool $new)
 
 getTypeHandlerForType (string $type)
 
 updateItem (ilMMItemFacadeInterface $item_facade)
 
 createItem (ilMMItemFacadeInterface $item_facade)
 
 deleteItem (ilMMItemFacadeInterface $item_facade)
 

Private Attributes

ilDBInterface $db
 
Services $services
 
MainMenuMainCollector $main_collector
 
ILIAS Cache Container Container $cache
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMMItemRepository::__construct ( )

ilMMItemRepository constructor.

Exceptions
Throwable

Definition at line 53 of file class.ilMMItemRepository.php.

References $DIC, and ilMMItemStorage\register().

54  {
55  global $DIC;
56  $this->cache = $DIC->globalCache()->get($this);
57  $this->db = $DIC->database();
58  $this->main_collector = $DIC->globalScreen()->collector()->mainmenu();
59  $this->main_collector->collectOnce();
60  $this->services = $DIC->globalScreen();
61 
62  foreach ($this->main_collector->getRawUnfilteredItems() as $top_item) {
63  ilMMItemStorage::register($top_item);
64  }
65  }
global $DIC
Definition: feed.php:28
static register(isItem $item)
+ Here is the call graph for this function:

Member Function Documentation

◆ clearCache()

ilMMItemRepository::clearCache ( )

Definition at line 78 of file class.ilMMItemRepository.php.

Referenced by createItem(), deleteItem(), and updateItem().

78  : void
79  {
80  $this->cache->flush();
81  }
+ Here is the caller graph for this function:

◆ createItem()

ilMMItemRepository::createItem ( ilMMItemFacadeInterface  $item_facade)
Parameters
ilMMItemFacadeInterface$item_facade

Definition at line 282 of file class.ilMMItemRepository.php.

References clearCache(), and ilMMItemFacadeInterface\create().

282  : void
283  {
284  $item_facade->create();
285  $this->clearCache();
286  }
+ Here is the call graph for this function:

◆ deleteItem()

ilMMItemRepository::deleteItem ( ilMMItemFacadeInterface  $item_facade)
Parameters
ilMMItemFacadeInterface$item_facade

Definition at line 291 of file class.ilMMItemRepository.php.

References clearCache(), ilMMItemFacadeInterface\delete(), and ilMMItemFacadeInterface\isDeletable().

291  : void
292  {
293  if ($item_facade->isDeletable()) {
294  $item_facade->delete();
295  $this->clearCache();
296  }
297  }
+ Here is the call graph for this function:

◆ flushLostItems()

ilMMItemRepository::flushLostItems ( )

Definition at line 138 of file class.ilMMItemRepository.php.

References getItemFacade(), getSubItemsForTable(), and getTopItems().

138  : void
139  {
140  foreach ($this->getTopItems() as $item) {
141  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
142  if (Lost::class === $item_facade->getType()) {
143  $item_facade->delete();
144  }
145  }
146 
147  foreach ($this->getSubItemsForTable() as $item) {
148  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
149  if (Lost::class === $item_facade->getType()) {
150  $item_facade->delete();
151  }
152  }
153  }
getItemFacade(IdentificationInterface $identification=null)
+ Here is the call graph for this function:

◆ getContainerKey()

ilMMItemRepository::getContainerKey ( )

Implements ILIAS\Cache\Container\Request.

Definition at line 67 of file class.ilMMItemRepository.php.

67  : string
68  {
69  return 'mm_items';
70  }

◆ getItemFacade()

ilMMItemRepository::getItemFacade ( IdentificationInterface  $identification = null)
Parameters
IdentificationInterface | null$identification
Returns
ilMMItemFacadeInterface
Exceptions
Throwable

Definition at line 178 of file class.ilMMItemRepository.php.

Referenced by flushLostItems(), getItemFacadeForIdentificationString(), getPossibleParentsForFormAndTable(), and hasLostItems().

179  {
180  if ($identification === null || $identification instanceof NullIdentification || $identification instanceof NullPluginIdentification) {
181  return new ilMMNullItemFacade($identification ?: new NullIdentification(), $this->main_collector);
182  }
183  if ($identification->getClassName() === CustomMainBarProvider::class) {
184  return new ilMMCustomItemFacade($identification, $this->main_collector);
185  }
186 
187  return new ilMMItemFacade($identification, $this->main_collector);
188  }
Class ilMMNullItemFacade.
Class ilMMItemFacade.
Class ilMMCustomItemFacade.
Interface ilMMItemFacadeInterface.
+ Here is the caller graph for this function:

◆ getItemFacadeForIdentificationString()

ilMMItemRepository::getItemFacadeForIdentificationString ( string  $identification)
Parameters
string$identification
Returns
ilMMItemFacadeInterface
Exceptions
Throwable

Definition at line 195 of file class.ilMMItemRepository.php.

References $id, and getItemFacade().

196  {
197  $id = $this->services->identification()->fromSerializedIdentification($identification);
198 
199  return $this->getItemFacade($id);
200  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getItemFacade(IdentificationInterface $identification=null)
Interface ilMMItemFacadeInterface.
+ Here is the call graph for this function:

◆ getPossibleParentsForFormAndTable()

ilMMItemRepository::getPossibleParentsForFormAndTable ( )

Definition at line 202 of file class.ilMMItemRepository.php.

References $data, getItemFacade(), getSingleItem(), and getTopItems().

202  : array
203  {
204  static $parents;
205  if ($parents === null) {
206  $parents = [];
207  foreach ($this->getTopItems() as $top_item_identification => $data) {
208  $identification = $this->services->identification()->fromSerializedIdentification($top_item_identification);
209  $item = $this->getSingleItem($identification);
210  if ($item instanceof TopParentItem) {
211  $parents[$top_item_identification] = $this->getItemFacade($identification)
212  ->getDefaultTitle();
213  }
214  }
215  }
216 
217  return $parents;
218  }
getItemFacade(IdentificationInterface $identification=null)
getSingleItem(IdentificationInterface $identification)
+ Here is the call graph for this function:

◆ getPossibleSubItemTypesWithInformation()

ilMMItemRepository::getPossibleSubItemTypesWithInformation ( )
Returns
[]

Definition at line 223 of file class.ilMMItemRepository.php.

223  : array
224  {
225  $types = [];
226  foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
227  if ($information->isCreationPrevented()) {
228  continue;
229  }
230  if ($information->isChild()) {
231  if ($information->getType() === TopLinkItem::class) { // since these two types are identical (more or less), we truncate one
232  continue;
233  }
234  $types[$information->getType()] = $information;
235  }
236  }
237 
238  return $types;
239  }

◆ getPossibleTopItemTypesWithInformation()

ilMMItemRepository::getPossibleTopItemTypesWithInformation ( bool  $new)
Returns
[]

Definition at line 244 of file class.ilMMItemRepository.php.

244  : array
245  {
246  $types = [];
247  foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
248  if (!$new || $information->isTop()) {
249  $types[$information->getType()] = $information;
250  }
251  }
252 
253  return $types;
254  }

◆ getSingleItem()

ilMMItemRepository::getSingleItem ( IdentificationInterface  $identification)
Parameters
IdentificationInterface$identification
Returns
isItem

Definition at line 87 of file class.ilMMItemRepository.php.

Referenced by getPossibleParentsForFormAndTable().

87  : isItem
88  {
89  return $this->main_collector->getSingleItemFromRaw($identification);
90  }
+ Here is the caller graph for this function:

◆ getSingleItemFromFilter()

ilMMItemRepository::getSingleItemFromFilter ( IdentificationInterface  $identification)

Definition at line 92 of file class.ilMMItemRepository.php.

92  : isItem
93  {
94  return $this->main_collector->getSingleItemFromFilter($identification);
95  }

◆ getSubItemsForTable()

ilMMItemRepository::getSubItemsForTable ( )
Returns
array

Definition at line 122 of file class.ilMMItemRepository.php.

References $data, and $r.

Referenced by flushLostItems(), and hasLostItems().

122  : array
123  {
124  $r = $this->db->query(
125  "SELECT sub_items.*, top_items.position AS parent_position
126 FROM il_mm_items AS sub_items
127 LEFT JOIN il_mm_items AS top_items ON top_items.identification = sub_items.parent_identification
128 WHERE sub_items.parent_identification != '' ORDER BY top_items.position, parent_identification, sub_items.position ASC"
129  );
130  $return = [];
131  while ($data = $this->db->fetchAssoc($r)) {
132  $return[] = $data;
133  }
134 
135  return $return;
136  }
$r
+ Here is the caller graph for this function:

◆ getTopItems()

ilMMItemRepository::getTopItems ( )
Returns
array
Exceptions
arException

Definition at line 114 of file class.ilMMItemRepository.php.

References ActiveRecord\where().

Referenced by flushLostItems(), getPossibleParentsForFormAndTable(), and hasLostItems().

114  : array
115  {
116  return ilMMItemStorage::where(" parent_identification = '' OR parent_identification IS NULL ")->orderBy('position')->getArray();
117  }
static where($where, $operator=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTypeHandlerForType()

ilMMItemRepository::getTypeHandlerForType ( string  $type)
Parameters
string$type
Returns
TypeHandler
Deprecated:

Definition at line 261 of file class.ilMMItemRepository.php.

261  : TypeHandler
262  {
263  $item = $this->services->mainBar()->custom($type, new NullIdentification());
264 
265  return $this->main_collector->getTypeHandlerForItem($item);
266  }

◆ hasLostItems()

ilMMItemRepository::hasLostItems ( )

Definition at line 155 of file class.ilMMItemRepository.php.

References getItemFacade(), getSubItemsForTable(), and getTopItems().

155  : bool
156  {
157  foreach ($this->getTopItems() as $item) {
158  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
159  if (Lost::class === $item_facade->getType()) {
160  return true;
161  }
162  }
163 
164  foreach ($this->getSubItemsForTable() as $item) {
165  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
166  if (Lost::class === $item_facade->getType()) {
167  return true;
168  }
169  }
170  return false;
171  }
getItemFacade(IdentificationInterface $identification=null)
+ Here is the call graph for this function:

◆ isForced()

ilMMItemRepository::isForced ( )

Implements ILIAS\Cache\Container\Request.

Definition at line 73 of file class.ilMMItemRepository.php.

73  : bool
74  {
75  return false;
76  }

◆ repository()

ilMMItemRepository::repository ( )
Returns
ilMMItemRepository

Definition at line 105 of file class.ilMMItemRepository.php.

106  {
107  return $this;
108  }
Class ilMMItemRepository.

◆ resolveIdentificationFromString()

ilMMItemRepository::resolveIdentificationFromString ( string  $identification_string)

Definition at line 97 of file class.ilMMItemRepository.php.

98  {
99  return $this->services->identification()->fromSerializedIdentification($identification_string);
100  }

◆ updateItem()

ilMMItemRepository::updateItem ( ilMMItemFacadeInterface  $item_facade)
Parameters
ilMMItemFacadeInterface$item_facade

Definition at line 271 of file class.ilMMItemRepository.php.

References clearCache(), ilMMItemFacadeInterface\isEditable(), and ilMMItemFacadeInterface\update().

271  : void
272  {
273  if ($item_facade->isEditable()) {
274  $item_facade->update();
275  $this->clearCache();
276  }
277  }
+ Here is the call graph for this function:

Field Documentation

◆ $cache

ILIAS Cache Container Container ilMMItemRepository::$cache
private

Definition at line 47 of file class.ilMMItemRepository.php.

◆ $db

ilDBInterface ilMMItemRepository::$db
private

Definition at line 41 of file class.ilMMItemRepository.php.

◆ $main_collector

MainMenuMainCollector ilMMItemRepository::$main_collector
private

Definition at line 45 of file class.ilMMItemRepository.php.

◆ $services

Services ilMMItemRepository::$services
private

Definition at line 43 of file class.ilMMItemRepository.php.


The documentation for this class was generated from the following file: