ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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
 
Container $cache
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMMItemRepository::__construct ( )

ilMMItemRepository constructor.

Exceptions
Throwable

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

References $DIC, and ilMMItemStorage\register().

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

Member Function Documentation

◆ clearCache()

ilMMItemRepository::clearCache ( )

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

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

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

◆ createItem()

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

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

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

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

◆ deleteItem()

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

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

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

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

◆ flushLostItems()

ilMMItemRepository::flushLostItems ( )

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

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

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

◆ getContainerKey()

ilMMItemRepository::getContainerKey ( )

Implements ILIAS\Cache\Container\Request.

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

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

◆ getItemFacade()

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

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

References null.

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

180  {
181  if ($identification === null || $identification instanceof NullIdentification || $identification instanceof NullPluginIdentification) {
182  return new ilMMNullItemFacade($identification ?: new NullIdentification(), $this->main_collector);
183  }
184  if ($identification->getClassName() === CustomMainBarProvider::class) {
185  return new ilMMCustomItemFacade($identification, $this->main_collector);
186  }
187 
188  return new ilMMItemFacade($identification, $this->main_collector);
189  }
Class ilMMNullItemFacade.
Class ilMMItemFacade.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 196 of file class.ilMMItemRepository.php.

References $id, and getItemFacade().

197  {
198  $id = $this->services->identification()->fromSerializedIdentification($identification);
199 
200  return $this->getItemFacade($id);
201  }
$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 203 of file class.ilMMItemRepository.php.

References getItemFacade(), getSingleItem(), getTopItems(), and null.

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

◆ getPossibleSubItemTypesWithInformation()

ilMMItemRepository::getPossibleSubItemTypesWithInformation ( )
Returns
TypeInformation[]

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

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

◆ getPossibleTopItemTypesWithInformation()

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

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

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

◆ getSingleItem()

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

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

Referenced by getPossibleParentsForFormAndTable().

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

◆ getSingleItemFromFilter()

ilMMItemRepository::getSingleItemFromFilter ( IdentificationInterface  $identification)

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

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

◆ getSubItemsForTable()

ilMMItemRepository::getSubItemsForTable ( )
Returns
array

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

References $data, and $r.

Referenced by flushLostItems(), and hasLostItems().

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

◆ getTopItems()

ilMMItemRepository::getTopItems ( )
Returns
array
Exceptions
arException

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

References ActiveRecord\where().

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

115  : array
116  {
117  return ilMMItemStorage::where(" parent_identification = '' OR parent_identification IS NULL ")->orderBy('position')->getArray();
118  }
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 262 of file class.ilMMItemRepository.php.

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

◆ hasLostItems()

ilMMItemRepository::hasLostItems ( )

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

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

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

◆ isForced()

ilMMItemRepository::isForced ( )

Implements ILIAS\Cache\Container\Request.

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

74  : bool
75  {
76  return false;
77  }

◆ repository()

ilMMItemRepository::repository ( )
Returns
ilMMItemRepository

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

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

◆ resolveIdentificationFromString()

ilMMItemRepository::resolveIdentificationFromString ( string  $identification_string)

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

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

◆ updateItem()

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

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

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

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

Field Documentation

◆ $cache

Container ilMMItemRepository::$cache
private

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

◆ $db

ilDBInterface ilMMItemRepository::$db
private

Definition at line 42 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: