ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ()
 
 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 42 of file class.ilMMItemRepository.php.

43 {
44 global $DIC;
46 $this->db = $DIC->database();
47 $this->main_collector = $DIC->globalScreen()->collector()->mainmenu();
48 $this->main_collector->collectOnce();
49 $this->services = $DIC->globalScreen();
50
51 foreach ($this->main_collector->getRawItems() as $top_item) {
53 }
54 }
static getInstance($component)
static register(isItem $item)
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

Member Function Documentation

◆ clearCache()

ilMMItemRepository::clearCache ( )

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

56 : void
57 {
58 $this->cache->flush();
59 }

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

+ Here is the caller graph for this function:

◆ createItem()

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

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

260 : void
261 {
262 $item_facade->create();
263 $this->clearCache();
264 }

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

+ Here is the call graph for this function:

◆ deleteItem()

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

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

269 : void
270 {
271 if ($item_facade->isDeletable()) {
272 $item_facade->delete();
273 $this->clearCache();
274 }
275 }

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

+ Here is the call graph for this function:

◆ flushLostItems()

ilMMItemRepository::flushLostItems ( )

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

117 {
118 foreach ($this->getTopItems() as $item) {
119 $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
120 if (Lost::class === $item_facade->getType()) {
121 $item_facade->delete();
122 }
123 }
124
125 foreach ($this->getSubItemsForTable() as $item) {
126 $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
127 if (Lost::class === $item_facade->getType()) {
128 $item_facade->delete();
129 }
130 }
131 }
getItemFacade(IdentificationInterface $identification=null)

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

+ 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 156 of file class.ilMMItemRepository.php.

157 {
158 if ($identification === null || $identification instanceof NullIdentification || $identification instanceof NullPluginIdentification) {
159 return new ilMMNullItemFacade($identification ? $identification : new NullIdentification(), $this->main_collector);
160 }
161 if ($identification->getClassName() === CustomMainBarProvider::class) {
162 return new ilMMCustomItemFacade($identification, $this->main_collector);
163 }
164
165 return new ilMMItemFacade($identification, $this->main_collector);
166 }
Class ilMMCustomItemFacade.
Class ilMMItemFacade.
Class ilMMNullItemFacade.
Interface ilMMItemFacadeInterface.

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

+ Here is the caller graph for this function:

◆ getItemFacadeForIdentificationString()

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

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

174 {
175 $id = $this->services->identification()->fromSerializedIdentification($identification);
176
177 return $this->getItemFacade($id);
178 }

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

+ Here is the call graph for this function:

◆ getPossibleParentsForFormAndTable()

ilMMItemRepository::getPossibleParentsForFormAndTable ( )

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

180 : array
181 {
182 static $parents;
183 if ($parents === null) {
184 $parents = [];
185 foreach ($this->getTopItems() as $top_item_identification => $data) {
186 $identification = $this->services->identification()->fromSerializedIdentification($top_item_identification);
187 $item = $this->getSingleItem($identification);
188 if ($item instanceof TopParentItem) {
189 $parents[$top_item_identification] = $this->getItemFacade($identification)
190 ->getDefaultTitle();
191 }
192 }
193 }
194
195 return $parents;
196 }
getSingleItem(IdentificationInterface $identification)
$data
Definition: storeScorm.php:23

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

+ Here is the call graph for this function:

◆ getPossibleSubItemTypesWithInformation()

ilMMItemRepository::getPossibleSubItemTypesWithInformation ( )
Returns
\ILIAS\GlobalScreen\Scope\MainMenu\Collector\Information\TypeInformation[]

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

201 : array
202 {
203 $types = [];
204 foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
205 if ($information->isCreationPrevented()) {
206 continue;
207 }
208 if ($information->isChild()) {
209 if ($information->getType() === TopLinkItem::class) { // since these two types are identical (more or less), we truncate one
210 continue;
211 }
212 $types[$information->getType()] = $information;
213 }
214 }
215
216 return $types;
217 }

◆ getPossibleTopItemTypesWithInformation()

ilMMItemRepository::getPossibleTopItemTypesWithInformation ( )
Returns
\ILIAS\GlobalScreen\Scope\MainMenu\Collector\Information\TypeInformation[]

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

222 : array
223 {
224 $types = [];
225 foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
226 if ($information->isTop()) {
227 $types[$information->getType()] = $information;
228 }
229 }
230
231 return $types;
232 }

◆ getSingleItem()

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

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

65 : isItem
66 {
67 return $this->main_collector->getSingleItemFromRaw($identification);
68 }

Referenced by getPossibleParentsForFormAndTable().

+ Here is the caller graph for this function:

◆ getSingleItemFromFilter()

ilMMItemRepository::getSingleItemFromFilter ( IdentificationInterface  $identification)

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

70 : isItem
71 {
72 return $this->main_collector->getSingleItemFromFilter($identification);
73 }

◆ getSubItemsForTable()

ilMMItemRepository::getSubItemsForTable ( )
Returns
array

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

100 : array
101 {
102 $r = $this->db->query(
103 "SELECT sub_items.*, top_items.position AS parent_position
104FROM il_mm_items AS sub_items
105LEFT JOIN il_mm_items AS top_items ON top_items.identification = sub_items.parent_identification
106WHERE sub_items.parent_identification != '' ORDER BY top_items.position, parent_identification, sub_items.position ASC"
107 );
108 $return = [];
109 while ($data = $this->db->fetchAssoc($r)) {
110 $return[] = $data;
111 }
112
113 return $return;
114 }

References $data.

Referenced by flushLostItems(), and hasLostItems().

+ Here is the caller graph for this function:

◆ getTopItems()

ilMMItemRepository::getTopItems ( )
Returns
array
Exceptions
arException

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

92 : array
93 {
94 return ilMMItemStorage::where(" parent_identification = '' OR parent_identification IS NULL ")->orderBy('position')->getArray();
95 }
static where($where, $operator=null)

References ActiveRecord\where().

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

+ 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 239 of file class.ilMMItemRepository.php.

240 {
241 $item = $this->services->mainBar()->custom($type, new NullIdentification());
242
243 return $this->main_collector->getTypeHandlerForItem($item);
244 }
$type

References $type.

◆ hasLostItems()

ilMMItemRepository::hasLostItems ( )

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

133 : bool
134 {
135 foreach ($this->getTopItems() as $item) {
136 $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
137 if (Lost::class === $item_facade->getType()) {
138 return true;
139 }
140 }
141
142 foreach ($this->getSubItemsForTable() as $item) {
143 $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
144 if (Lost::class === $item_facade->getType()) {
145 return true;
146 }
147 }
148 return false;
149 }

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

+ Here is the call graph for this function:

◆ repository()

ilMMItemRepository::repository ( )
Returns
ilMMItemRepository

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

84 {
85 return $this;
86 }
Class ilMMItemRepository.

◆ resolveIdentificationFromString()

ilMMItemRepository::resolveIdentificationFromString ( string  $identification_string)

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

76 {
77 return $this->services->identification()->fromSerializedIdentification($identification_string);
78 }

◆ updateItem()

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

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

249 : void
250 {
251 if ($item_facade->isEditable()) {
252 $item_facade->update();
253 $this->clearCache();
254 }
255 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $cache

ilMMItemRepository::$cache
private

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

◆ $db

ilMMItemRepository::$db
private

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

◆ $main_collector

ilMMItemRepository::$main_collector
private

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

◆ $services

ilMMItemRepository::$services
private

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


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