ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMMItemRepository Class Reference

Class ilMMItemRepository. More...

+ Collaboration diagram for ilMMItemRepository:

Public Member Functions

 __construct ()
 ilMMItemRepository constructor. More...
 
 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
 
ilGlobalCache $cache
 
Services $services
 
MainMenuMainCollector $main_collector
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMMItemRepository::__construct ( )

ilMMItemRepository constructor.

Exceptions
Throwable

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

References $DIC, ilGlobalCache\COMP_GLOBAL_SCREEN, ilGlobalCache\getInstance(), and ilMMItemStorage\register().

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

Member Function Documentation

◆ clearCache()

ilMMItemRepository::clearCache ( )

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

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

66  : void
67  {
68  $this->cache->flush();
69  }
+ Here is the caller graph for this function:

◆ createItem()

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

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

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

270  : void
271  {
272  $item_facade->create();
273  $this->clearCache();
274  }
+ Here is the call graph for this function:

◆ deleteItem()

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

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

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

279  : void
280  {
281  if ($item_facade->isDeletable()) {
282  $item_facade->delete();
283  $this->clearCache();
284  }
285  }
+ Here is the call graph for this function:

◆ flushLostItems()

ilMMItemRepository::flushLostItems ( )

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

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

126  : void
127  {
128  foreach ($this->getTopItems() as $item) {
129  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
130  if (Lost::class === $item_facade->getType()) {
131  $item_facade->delete();
132  }
133  }
134 
135  foreach ($this->getSubItemsForTable() as $item) {
136  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
137  if (Lost::class === $item_facade->getType()) {
138  $item_facade->delete();
139  }
140  }
141  }
getItemFacade(IdentificationInterface $identification=null)
+ Here is the call graph for this function:

◆ getItemFacade()

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

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

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

167  {
168  if ($identification === null || $identification instanceof NullIdentification || $identification instanceof NullPluginIdentification) {
169  return new ilMMNullItemFacade($identification ?: new NullIdentification(), $this->main_collector);
170  }
171  if ($identification->getClassName() === CustomMainBarProvider::class) {
172  return new ilMMCustomItemFacade($identification, $this->main_collector);
173  }
174 
175  return new ilMMItemFacade($identification, $this->main_collector);
176  }
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 183 of file class.ilMMItemRepository.php.

References $id, and getItemFacade().

184  {
185  $id = $this->services->identification()->fromSerializedIdentification($identification);
186 
187  return $this->getItemFacade($id);
188  }
$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 190 of file class.ilMMItemRepository.php.

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

190  : array
191  {
192  static $parents;
193  if ($parents === null) {
194  $parents = [];
195  foreach ($this->getTopItems() as $top_item_identification => $data) {
196  $identification = $this->services->identification()->fromSerializedIdentification($top_item_identification);
197  $item = $this->getSingleItem($identification);
198  if ($item instanceof TopParentItem) {
199  $parents[$top_item_identification] = $this->getItemFacade($identification)
200  ->getDefaultTitle();
201  }
202  }
203  }
204 
205  return $parents;
206  }
getItemFacade(IdentificationInterface $identification=null)
getSingleItem(IdentificationInterface $identification)
+ Here is the call graph for this function:

◆ getPossibleSubItemTypesWithInformation()

ilMMItemRepository::getPossibleSubItemTypesWithInformation ( )
Returns
[]

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

211  : array
212  {
213  $types = [];
214  foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
215  if ($information->isCreationPrevented()) {
216  continue;
217  }
218  if ($information->isChild()) {
219  if ($information->getType() === TopLinkItem::class) { // since these two types are identical (more or less), we truncate one
220  continue;
221  }
222  $types[$information->getType()] = $information;
223  }
224  }
225 
226  return $types;
227  }

◆ getPossibleTopItemTypesWithInformation()

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

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

232  : array
233  {
234  $types = [];
235  foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
236  if (!$new || $information->isTop()) {
237  $types[$information->getType()] = $information;
238  }
239  }
240 
241  return $types;
242  }

◆ getSingleItem()

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

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

Referenced by getPossibleParentsForFormAndTable().

75  : isItem
76  {
77  return $this->main_collector->getSingleItemFromRaw($identification);
78  }
+ Here is the caller graph for this function:

◆ getSingleItemFromFilter()

ilMMItemRepository::getSingleItemFromFilter ( IdentificationInterface  $identification)

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

80  : isItem
81  {
82  return $this->main_collector->getSingleItemFromFilter($identification);
83  }

◆ getSubItemsForTable()

ilMMItemRepository::getSubItemsForTable ( )
Returns
array

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

References $data.

Referenced by flushLostItems(), and hasLostItems().

110  : array
111  {
112  $r = $this->db->query(
113  "SELECT sub_items.*, top_items.position AS parent_position
114 FROM il_mm_items AS sub_items
115 LEFT JOIN il_mm_items AS top_items ON top_items.identification = sub_items.parent_identification
116 WHERE sub_items.parent_identification != '' ORDER BY top_items.position, parent_identification, sub_items.position ASC"
117  );
118  $return = [];
119  while ($data = $this->db->fetchAssoc($r)) {
120  $return[] = $data;
121  }
122 
123  return $return;
124  }
+ Here is the caller graph for this function:

◆ getTopItems()

ilMMItemRepository::getTopItems ( )
Returns
array
Exceptions
arException

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

References ActiveRecord\where().

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

102  : array
103  {
104  return ilMMItemStorage::where(" parent_identification = '' OR parent_identification IS NULL ")->orderBy('position')->getArray();
105  }
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 249 of file class.ilMMItemRepository.php.

249  : TypeHandler
250  {
251  $item = $this->services->mainBar()->custom($type, new NullIdentification());
252 
253  return $this->main_collector->getTypeHandlerForItem($item);
254  }
$type

◆ hasLostItems()

ilMMItemRepository::hasLostItems ( )

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

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

143  : bool
144  {
145  foreach ($this->getTopItems() as $item) {
146  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
147  if (Lost::class === $item_facade->getType()) {
148  return true;
149  }
150  }
151 
152  foreach ($this->getSubItemsForTable() as $item) {
153  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
154  if (Lost::class === $item_facade->getType()) {
155  return true;
156  }
157  }
158  return false;
159  }
getItemFacade(IdentificationInterface $identification=null)
+ Here is the call graph for this function:

◆ repository()

ilMMItemRepository::repository ( )
Returns
ilMMItemRepository

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

94  {
95  return $this;
96  }
Class ilMMItemRepository.

◆ resolveIdentificationFromString()

ilMMItemRepository::resolveIdentificationFromString ( string  $identification_string)

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

86  {
87  return $this->services->identification()->fromSerializedIdentification($identification_string);
88  }

◆ updateItem()

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

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

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

259  : void
260  {
261  if ($item_facade->isEditable()) {
262  $item_facade->update();
263  $this->clearCache();
264  }
265  }
+ Here is the call graph for this function:

Field Documentation

◆ $cache

ilGlobalCache ilMMItemRepository::$cache
private

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

◆ $db

ilDBInterface ilMMItemRepository::$db
private

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

◆ $main_collector

MainMenuMainCollector ilMMItemRepository::$main_collector
private

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

◆ $services

Services ilMMItemRepository::$services
private

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


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