ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMMItemRepository Class Reference
+ 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 (?ilMMItemFacadeInterface $parent=null)
 
 flushLostItems ()
 
 hasLostItems ()
 
 getItemFacade (?IdentificationInterface $identification=null)
 
 getItemFacadesForIdentificationStrings (array $identifications)
 
 getItemFacadeForIdentificationString (string $identification)
 
 getPossibleParentsForFormAndTable ()
 
 getPossibleSubItemTypesWithInformation ()
 
 getPossibleTopItemTypesWithInformation (bool $new)
 
 getTypeHandlerForType (string $type)
 
 updateItem (ilMMItemFacadeInterface $item_facade)
 
 createItem (ilMMItemFacadeInterface $item_facade)
 
 deleteItem (ilMMItemFacadeInterface $item_facade)
 
 getContainerKey ()
 
 isForced ()
 

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.

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) {
65 }
66 }
static register(isItem $item)
global $DIC
Definition: shib_login.php:26

References $DIC, and ilMMItemStorage\register().

+ Here is the call graph for this function:

Member Function Documentation

◆ clearCache()

ilMMItemRepository::clearCache ( )

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

78 : void
79 {
80 $this->cache->flush();
81 }

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

+ Here is the caller graph for this function:

◆ createItem()

ilMMItemRepository::createItem ( ilMMItemFacadeInterface  $item_facade)

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

296 : void
297 {
298 $item_facade->create();
299 $this->clearCache();
300 }

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

+ Here is the call graph for this function:

◆ deleteItem()

ilMMItemRepository::deleteItem ( ilMMItemFacadeInterface  $item_facade)

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

302 : void
303 {
304 if ($item_facade->isDeletable()) {
305 $item_facade->delete();
306 $this->clearCache();
307 }
308 }

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

+ Here is the call graph for this function:

◆ flushLostItems()

ilMMItemRepository::flushLostItems ( )

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

142 : void
143 {
144 foreach ($this->getTopItems() as $item) {
145 $item_facade = $this->getItemFacade(
146 $this->services->identification()->fromSerializedIdentification($item['identification'])
147 );
148 if (Lost::class === $item_facade->getType()) {
149 $item_facade->delete();
150 }
151 }
152
153 foreach ($this->getSubItemsForTable() as $item) {
154 $item_facade = $this->getItemFacade(
155 $this->services->identification()->fromSerializedIdentification($item['identification'])
156 );
157 if (Lost::class === $item_facade->getType()) {
158 $item_facade->delete();
159 }
160 }
161 }
getSubItemsForTable(?ilMMItemFacadeInterface $parent=null)
getItemFacade(?IdentificationInterface $identification=null)

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

+ 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)
Exceptions
Throwable

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

189 {
190 if ($identification === null || $identification instanceof NullIdentification || $identification instanceof NullPluginIdentification) {
191 return new ilMMNullItemFacade($identification ?: new NullIdentification(), $this->main_collector);
192 }
193 if ($identification->getClassName() === CustomMainBarProvider::class) {
194 return new ilMMCustomItemFacade($identification, $this->main_collector);
195 }
196
197 return new ilMMItemFacade($identification, $this->main_collector);
198 }
Class ilMMCustomItemFacade.
Class ilMMItemFacade.
Class ilMMNullItemFacade.
Interface ilMMItemFacadeInterface.

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

+ Here is the caller graph for this function:

◆ getItemFacadeForIdentificationString()

ilMMItemRepository::getItemFacadeForIdentificationString ( string  $identification)
Exceptions
Throwable

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

215 {
216 $id = $this->services->identification()->fromSerializedIdentification($identification);
217
218 return $this->getItemFacade($id);
219 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, and getItemFacade().

+ Here is the call graph for this function:

◆ getItemFacadesForIdentificationStrings()

ilMMItemRepository::getItemFacadesForIdentificationStrings ( array  $identifications)

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

200 : array
201 {
202 $item_facades = [];
203 foreach ($identifications as $identification) {
204 $id = $this->services->identification()->fromSerializedIdentification($identification);
205 $item_facades[] = $this->getItemFacade($id);
206 }
207
208 return $item_facades;
209 }

References $id, and getItemFacade().

+ Here is the call graph for this function:

◆ getPossibleParentsForFormAndTable()

ilMMItemRepository::getPossibleParentsForFormAndTable ( )

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

221 : array
222 {
223 static $parents;
224 if ($parents === null) {
225 $parents = [];
226 foreach (array_keys($this->getTopItems()) as $top_item_identification) {
227 $identification = $this->services->identification()->fromSerializedIdentification(
228 $top_item_identification
229 );
230 $item = $this->getSingleItem($identification);
231 if ($item instanceof TopParentItem) {
232 $parents[$top_item_identification] = $this->getItemFacade($identification)
233 ->getDefaultTitle();
234 }
235 }
236 }
237
238 return $parents;
239 }
getSingleItem(IdentificationInterface $identification)

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

+ Here is the call graph for this function:

◆ getPossibleSubItemTypesWithInformation()

ilMMItemRepository::getPossibleSubItemTypesWithInformation ( )
Returns
TypeInformation[]

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 ($information->isCreationPrevented()) {
249 continue;
250 }
251 if ($information->isChild()) {
252 // since these two types are identical (more or less), we truncate one
253 if ($information->getType() === TopLinkItem::class) {
254 continue;
255 }
256 $types[$information->getType()] = $information;
257 }
258 }
259
260 return $types;
261 }

◆ getPossibleTopItemTypesWithInformation()

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

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

266 : array
267 {
268 $types = [];
269 foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
270 if (!$new || $information->isTop()) {
271 $types[$information->getType()] = $information;
272 }
273 }
274
275 return $types;
276 }

◆ getSingleItem()

ilMMItemRepository::getSingleItem ( IdentificationInterface  $identification)

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

83 : isItem
84 {
85 return $this->main_collector->getSingleItemFromRaw($identification);
86 }

Referenced by getPossibleParentsForFormAndTable().

+ 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 ( ?ilMMItemFacadeInterface  $parent = null)

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

113 : array
114 {
115 if ($parent !== null) {
116 $r = $this->db->queryF(
117 "SELECT sub_items.*, top_items.position AS parent_position
118FROM il_mm_items AS sub_items
119LEFT JOIN il_mm_items AS top_items ON top_items.identification = sub_items.parent_identification
120WHERE sub_items.parent_identification != '' AND sub_items.parent_identification = %s
121ORDER BY top_items.position, parent_identification, sub_items.position ASC",
122 ['text'],
123 [$parent->identification()->serialize()]
124 );
125 } else {
126 $r = $this->db->query(
127 "SELECT sub_items.*, top_items.position AS parent_position
128FROM il_mm_items AS sub_items
129LEFT JOIN il_mm_items AS top_items ON top_items.identification = sub_items.parent_identification
130WHERE sub_items.parent_identification != ''
131ORDER BY top_items.position, parent_identification, sub_items.position ASC",
132 );
133 }
134 $return = [];
135 while ($data = $this->db->fetchAssoc($r)) {
136 $return[] = $data;
137 }
138
139 return $return;
140 }

References $data.

Referenced by flushLostItems(), and hasLostItems().

+ Here is the caller graph for this function:

◆ getTopItems()

ilMMItemRepository::getTopItems ( )
Exceptions
arException

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

106 : array
107 {
108 return ilMMItemStorage::where(" parent_identification = '' OR parent_identification IS NULL ")->orderBy(
109 'position'
110 )->getArray();
111 }
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)
Deprecated:

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

282 {
283 $item = $this->services->mainBar()->custom($type, new NullIdentification());
284
285 return $this->main_collector->getTypeHandlerForItem($item);
286 }

◆ hasLostItems()

ilMMItemRepository::hasLostItems ( )

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

163 : bool
164 {
165 foreach ($this->getTopItems() as $item) {
166 $item_facade = $this->getItemFacade(
167 $this->services->identification()->fromSerializedIdentification($item['identification'])
168 );
169 if (Lost::class === $item_facade->getType()) {
170 return true;
171 }
172 }
173
174 foreach ($this->getSubItemsForTable() as $item) {
175 $item_facade = $this->getItemFacade(
176 $this->services->identification()->fromSerializedIdentification($item['identification'])
177 );
178 if (Lost::class === $item_facade->getType()) {
179 return true;
180 }
181 }
182 return false;
183 }

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

+ 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 ( )

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

99 {
100 return $this;
101 }

◆ 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)

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

288 : void
289 {
290 if ($item_facade->isEditable()) {
291 $item_facade->update();
292 $this->clearCache();
293 }
294 }

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

+ 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: