ILIAS  release_7 Revision v7.30-3-g800a261c036
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

 $db
 
 $cache
 
 $services
 
 $main_collector
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMMItemRepository::__construct ( )

ilMMItemRepository constructor.

Exceptions
Throwable

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

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

61  {
62  global $DIC;
64  $this->db = $DIC->database();
65  $this->main_collector = $DIC->globalScreen()->collector()->mainmenu();
66  $this->main_collector->collectOnce();
67  $this->services = $DIC->globalScreen();
68 
69  foreach ($this->main_collector->getRawUnfilteredItems() as $top_item) {
70  ilMMItemStorage::register($top_item);
71  }
72  }
static getInstance($component)
static register(isItem $item)
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

Member Function Documentation

◆ clearCache()

ilMMItemRepository::clearCache ( )

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

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

74  : void
75  {
76  $this->cache->flush();
77  }
+ Here is the caller graph for this function:

◆ createItem()

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

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

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

278  : void
279  {
280  $item_facade->create();
281  $this->clearCache();
282  }
+ Here is the call graph for this function:

◆ deleteItem()

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

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

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

287  : void
288  {
289  if ($item_facade->isDeletable()) {
290  $item_facade->delete();
291  $this->clearCache();
292  }
293  }
+ Here is the call graph for this function:

◆ flushLostItems()

ilMMItemRepository::flushLostItems ( )

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

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

135  {
136  foreach ($this->getTopItems() as $item) {
137  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
138  if (Lost::class === $item_facade->getType()) {
139  $item_facade->delete();
140  }
141  }
142 
143  foreach ($this->getSubItemsForTable() as $item) {
144  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
145  if (Lost::class === $item_facade->getType()) {
146  $item_facade->delete();
147  }
148  }
149  }
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 174 of file class.ilMMItemRepository.php.

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

175  {
176  if ($identification === null || $identification instanceof NullIdentification || $identification instanceof NullPluginIdentification) {
177  return new ilMMNullItemFacade($identification ? $identification : new NullIdentification(), $this->main_collector);
178  }
179  if ($identification->getClassName() === CustomMainBarProvider::class) {
180  return new ilMMCustomItemFacade($identification, $this->main_collector);
181  }
182 
183  return new ilMMItemFacade($identification, $this->main_collector);
184  }
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 191 of file class.ilMMItemRepository.php.

References getItemFacade(), and ilMMItemFacadeInterface\identification().

192  {
193  $id = $this->services->identification()->fromSerializedIdentification($identification);
194 
195  return $this->getItemFacade($id);
196  }
getItemFacade(IdentificationInterface $identification=null)
Interface ilMMItemFacadeInterface.
+ Here is the call graph for this function:

◆ getPossibleParentsForFormAndTable()

ilMMItemRepository::getPossibleParentsForFormAndTable ( )

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

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

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

◆ getPossibleSubItemTypesWithInformation()

ilMMItemRepository::getPossibleSubItemTypesWithInformation ( )
Returns
[]

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

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

◆ getPossibleTopItemTypesWithInformation()

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

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

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

◆ getSingleItem()

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

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

Referenced by getPossibleParentsForFormAndTable().

83  : isItem
84  {
85  return $this->main_collector->getSingleItemFromRaw($identification);
86  }
+ Here is the caller graph for this function:

◆ getSingleItemFromFilter()

ilMMItemRepository::getSingleItemFromFilter ( IdentificationInterface  $identification)

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

88  : isItem
89  {
90  return $this->main_collector->getSingleItemFromFilter($identification);
91  }

◆ getSubItemsForTable()

ilMMItemRepository::getSubItemsForTable ( )
Returns
array

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

References $data.

Referenced by flushLostItems(), and hasLostItems().

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

◆ getTopItems()

ilMMItemRepository::getTopItems ( )
Returns
array
Exceptions
arException

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

References ActiveRecord\where().

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

110  : array
111  {
112  return ilMMItemStorage::where(" parent_identification = '' OR parent_identification IS NULL ")->orderBy('position')->getArray();
113  }
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 257 of file class.ilMMItemRepository.php.

257  : TypeHandler
258  {
259  $item = $this->services->mainBar()->custom($type, new NullIdentification());
260 
261  return $this->main_collector->getTypeHandlerForItem($item);
262  }
$type

◆ hasLostItems()

ilMMItemRepository::hasLostItems ( )

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

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

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

◆ repository()

ilMMItemRepository::repository ( )
Returns
ilMMItemRepository

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

102  {
103  return $this;
104  }
Class ilMMItemRepository.

◆ resolveIdentificationFromString()

ilMMItemRepository::resolveIdentificationFromString ( string  $identification_string)

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

94  {
95  return $this->services->identification()->fromSerializedIdentification($identification_string);
96  }

◆ updateItem()

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

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

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

267  : void
268  {
269  if ($item_facade->isEditable()) {
270  $item_facade->update();
271  $this->clearCache();
272  }
273  }
+ Here is the call graph for this function:

Field Documentation

◆ $cache

ilMMItemRepository::$cache
private

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

◆ $db

ilMMItemRepository::$db
private

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

◆ $main_collector

ilMMItemRepository::$main_collector
private

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

◆ $services

ilMMItemRepository::$services
private

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


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