ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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 ()
 
 getLostItems ()
 
 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 53 of file class.ilMMItemRepository.php.

54 {
55 global $DIC;
56 $this->cache = $DIC->globalCache()->get($this);
57 $this->db = $DIC->database();
58 $this->main_collector = $DIC->globalScreen()->collector()->mainmenu();
59 $this->main_collector->collectOnce();
60 $this->services = $DIC->globalScreen();
61
62 foreach ($this->main_collector->getRawUnfilteredItems() as $top_item) {
64 }
65 }
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 77 of file class.ilMMItemRepository.php.

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

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

+ Here is the caller graph for this function:

◆ createItem()

ilMMItemRepository::createItem ( ilMMItemFacadeInterface  $item_facade)

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

286 : void
287 {
288 $item_facade->create();
289 $this->clearCache();
290 }

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

+ Here is the call graph for this function:

◆ deleteItem()

ilMMItemRepository::deleteItem ( ilMMItemFacadeInterface  $item_facade)

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

292 : void
293 {
294 if ($item_facade->isDeletable()) {
295 $item_facade->delete();
296 $this->clearCache();
297 }
298 }

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

+ Here is the call graph for this function:

◆ flushLostItems()

ilMMItemRepository::flushLostItems ( )

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

160 : void
161 {
162 foreach ($this->getLostItems() as $item) {
163 $item_facade = $this->getItemFacade(
164 $this->services->identification()->fromSerializedIdentification($item['identification'])
165 );
166 $item_facade->delete();
167 }
168 }
getItemFacade(?IdentificationInterface $identification=null)

References getItemFacade(), and getLostItems().

+ Here is the call graph for this function:

◆ getContainerKey()

ilMMItemRepository::getContainerKey ( )

Implements ILIAS\Cache\Container\Request.

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

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

◆ getItemFacade()

ilMMItemRepository::getItemFacade ( ?IdentificationInterface  $identification = null)
Exceptions
Throwable

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

179 {
180 if ($identification === null || $identification instanceof NullIdentification || $identification instanceof NullPluginIdentification) {
181 return new ilMMNullItemFacade($identification ?: new NullIdentification(), $this->main_collector);
182 }
183 if ($identification->getClassName() === CustomMainBarProvider::class) {
184 return new ilMMCustomItemFacade($identification, $this->main_collector);
185 }
186
187 return new ilMMItemFacade($identification, $this->main_collector);
188 }
Class ilMMCustomItemFacade.
Class ilMMItemFacade.
Class ilMMNullItemFacade.
Interface ilMMItemFacadeInterface.

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

+ Here is the caller graph for this function:

◆ getItemFacadeForIdentificationString()

ilMMItemRepository::getItemFacadeForIdentificationString ( string  $identification)
Exceptions
Throwable

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

205 {
206 $id = $this->services->identification()->fromSerializedIdentification($identification);
207
208 return $this->getItemFacade($id);
209 }
$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 190 of file class.ilMMItemRepository.php.

190 : array
191 {
192 $item_facades = [];
193 foreach ($identifications as $identification) {
194 $id = $this->services->identification()->fromSerializedIdentification($identification);
195 $item_facades[] = $this->getItemFacade($id);
196 }
197
198 return $item_facades;
199 }

References $id, and getItemFacade().

+ Here is the call graph for this function:

◆ getLostItems()

ilMMItemRepository::getLostItems ( )

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

112 : array
113 {
114 $q = "SELECT sub_items.* " .
115 "FROM il_mm_items AS sub_items " .
116 "LEFT JOIN il_mm_items AS top_items ON top_items.identification = sub_items.parent_identification " .
117 "WHERE sub_items.parent_identification != '' AND sub_items.parent_identification IS NOT NULL " .
118 "AND (top_items.identification IS NULL OR top_items.identification = '') " .
119 "ORDER BY top_items.position, parent_identification, sub_items.position ASC";
120
121 $r = $this->db->query($q);
122 $return = [];
123 while ($data = $this->db->fetchAssoc($r)) {
124 $return[] = $data;
125 }
126
127 return $return;
128 }
$q
Definition: shib_logout.php:25

References $data, and $q.

Referenced by flushLostItems(), and hasLostItems().

+ Here is the caller graph for this function:

◆ getPossibleParentsForFormAndTable()

ilMMItemRepository::getPossibleParentsForFormAndTable ( )

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

211 : array
212 {
213 static $parents;
214 if ($parents === null) {
215 $parents = [];
216 foreach (array_keys($this->getTopItems()) as $top_item_identification) {
217 $identification = $this->services->identification()->fromSerializedIdentification(
218 $top_item_identification
219 );
220 $item = $this->getSingleItem($identification);
221 if ($item instanceof TopParentItem) {
222 $parents[$top_item_identification] = $this->getItemFacade($identification)
223 ->getDefaultTitle();
224 }
225 }
226 }
227
228 return $parents;
229 }
getSingleItem(IdentificationInterface $identification)

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

+ Here is the call graph for this function:

◆ getPossibleSubItemTypesWithInformation()

ilMMItemRepository::getPossibleSubItemTypesWithInformation ( )
Returns
TypeInformation[]

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

234 : array
235 {
236 $types = [];
237 foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
238 if ($information->isCreationPrevented()) {
239 continue;
240 }
241 if ($information->isChild()) {
242 // since these two types are identical (more or less), we truncate one
243 if ($information->getType() === TopLinkItem::class) {
244 continue;
245 }
246 $types[$information->getType()] = $information;
247 }
248 }
249
250 return $types;
251 }

◆ getPossibleTopItemTypesWithInformation()

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

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

256 : array
257 {
258 $types = [];
259 foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
260 if (!$new || $information->isTop()) {
261 $types[$information->getType()] = $information;
262 }
263 }
264
265 return $types;
266 }

◆ getSingleItem()

ilMMItemRepository::getSingleItem ( IdentificationInterface  $identification)

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

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

Referenced by getPossibleParentsForFormAndTable().

+ Here is the caller graph for this function:

◆ getSingleItemFromFilter()

ilMMItemRepository::getSingleItemFromFilter ( IdentificationInterface  $identification)

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

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

◆ getSubItemsForTable()

ilMMItemRepository::getSubItemsForTable ( ?ilMMItemFacadeInterface  $parent = null)

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

131 : array
132 {
133 if ($parent !== null) {
134 $r = $this->db->queryF(
135 "SELECT sub_items.*, top_items.position AS parent_position
136FROM il_mm_items AS sub_items
137LEFT JOIN il_mm_items AS top_items ON top_items.identification = sub_items.parent_identification
138WHERE sub_items.parent_identification != '' AND sub_items.parent_identification = %s
139ORDER BY top_items.position, parent_identification, sub_items.position ASC",
140 ['text'],
141 [$parent->identification()->serialize()]
142 );
143 } else {
144 $r = $this->db->query(
145 "SELECT sub_items.*, top_items.position AS parent_position
146FROM il_mm_items AS sub_items
147LEFT JOIN il_mm_items AS top_items ON top_items.identification = sub_items.parent_identification
148WHERE sub_items.parent_identification != ''
149ORDER BY top_items.position, parent_identification, sub_items.position ASC",
150 );
151 }
152 $return = [];
153 while ($data = $this->db->fetchAssoc($r)) {
154 $return[] = $data;
155 }
156
157 return $return;
158 }

References $data.

◆ getTopItems()

ilMMItemRepository::getTopItems ( )
Exceptions
arException

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

105 : array
106 {
107 return ilMMItemStorage::where(" parent_identification = '' OR parent_identification IS NULL ")->orderBy(
108 'position'
109 )->getArray();
110 }
static where($where, $operator=null)

References ActiveRecord\where().

Referenced by getPossibleParentsForFormAndTable().

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

272 {
273 $item = $this->services->mainBar()->custom($type, new NullIdentification());
274
275 return $this->main_collector->getTypeHandlerForItem($item);
276 }

◆ hasLostItems()

ilMMItemRepository::hasLostItems ( )

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

170 : bool
171 {
172 return count($this->getLostItems()) > 0;
173 }

References getLostItems().

+ Here is the call graph for this function:

◆ isForced()

ilMMItemRepository::isForced ( )

Implements ILIAS\Cache\Container\Request.

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

72 : bool
73 {
74 return false;
75 }

◆ repository()

ilMMItemRepository::repository ( )

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

98 {
99 return $this;
100 }

◆ resolveIdentificationFromString()

ilMMItemRepository::resolveIdentificationFromString ( string  $identification_string)

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

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

◆ updateItem()

ilMMItemRepository::updateItem ( ilMMItemFacadeInterface  $item_facade)

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

278 : void
279 {
280 if ($item_facade->isEditable()) {
281 $item_facade->update();
282 $this->clearCache();
283 }
284 }

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

◆ $db

ilDBInterface ilMMItemRepository::$db
private

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

◆ $main_collector

MainMenuMainCollector ilMMItemRepository::$main_collector
private

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

◆ $services

Services ilMMItemRepository::$services
private

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


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