ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMMItemRepository Class Reference

Class ilMMItemRepository. More...

+ Collaboration diagram for ilMMItemRepository:

Public Member Functions

 __construct ()
 ilMMItemRepository constructor. More...
 
 getEmptyItemForTypeString (string $class_name)
 
 clearCache ()
 
 getStackedTopItemsForPresentation ()
 
 getSingleItem (IdentificationInterface $identification)
 
 repository ()
 
 getTopItems ()
 
 getSubItemsForTable ()
 
 flushLostItems ()
 
 hasLostItems ()
 
 getItemFacade (IdentificationInterface $identification=null)
 
 getItemFacadeForIdentificationString (string $identification)
 
 getPossibleParentsForFormAndTable ()
 
 getPossibleSubItemTypesForForm ()
 
 getPossibleSubItemTypesWithInformation ()
 
 getPossibleTopItemTypesForForm ()
 
 getPossibleTopItemTypesWithInformation ()
 
 getTypeHandlerForType (string $type)
 
 updateItem (ilMMItemFacadeInterface $item_facade)
 
 createItem (ilMMItemFacadeInterface $item_facade)
 
 deleteItem (ilMMItemFacadeInterface $item_facade)
 

Private Member Functions

 sync ()
 

Private Attributes

 $services
 
 $synced = false
 
 $storage
 
 $main_collector
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMMItemRepository::__construct ( )

ilMMItemRepository constructor.

Exceptions
Throwable

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

References $DIC, ilMMItemStorage\register(), and sync().

47  {
48  global $DIC;
49  $this->storage = new CoreStorageFacade();
50  $this->main_collector = $DIC->globalScreen()->collector()->mainmenu();
51  $this->services = $DIC->globalScreen();
52 
53  foreach ($this->main_collector->getStackedTopItemsForPresentation() as $top_item) {
54  ilMMItemStorage::register($top_item);
55  if ($top_item instanceof isParent) {
56  foreach ($top_item->getChildren() as $child) {
58  }
59  }
60  }
61  $this->sync();
62  }
global $DIC
Definition: saml.php:7
static register(isItem $item)
+ Here is the call graph for this function:

Member Function Documentation

◆ clearCache()

ilMMItemRepository::clearCache ( )

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

99  {
100  $this->storage->cache()->flush();
101  }

◆ createItem()

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

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

References ilMMItemFacadeInterface\create().

360  {
361  $item_facade->create();
362  $this->storage->cache()->flush();
363  }
+ Here is the call graph for this function:

◆ deleteItem()

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

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

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

370  {
371  if ($item_facade->isDeletable()) {
372  $item_facade->delete();
373  $this->storage->cache()->flush();
374  }
375  }
+ Here is the call graph for this function:

◆ flushLostItems()

ilMMItemRepository::flushLostItems ( )

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

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

167  {
168  foreach ($this->getTopItems() as $item) {
169  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
170  if (Lost::class === $item_facade->getType()) {
171  $item_facade->delete();
172  }
173  }
174 
175  foreach ($this->getSubItemsForTable() as $item) {
176  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
177  if (Lost::class === $item_facade->getType()) {
178  $item_facade->delete();
179  }
180  }
181  }
getItemFacade(IdentificationInterface $identification=null)
+ Here is the call graph for this function:

◆ getEmptyItemForTypeString()

ilMMItemRepository::getEmptyItemForTypeString ( string  $class_name)
Parameters
string$class_name
Returns
isItem

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

92  : isItem
93  {
94  return $this->services->mainmenu()->custom($class_name, new NullIdentification());
95  }

◆ getItemFacade()

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

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

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

209  {
210  if ($identification === null || $identification instanceof NullIdentification || $identification instanceof NullPluginIdentification) {
211  return new ilMMNullItemFacade($identification ? $identification : new NullIdentification(), $this->main_collector);
212  }
213  if ($identification->getClassName() === ilMMCustomProvider::class) {
214  return new ilMMCustomItemFacade($identification, $this->main_collector);
215  }
216 
217  return new ilMMItemFacade($identification, $this->main_collector);
218  }
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 227 of file class.ilMMItemRepository.php.

References $id, and getItemFacade().

228  {
229  $id = $this->services->identification()->fromSerializedIdentification($identification);
230 
231  return $this->getItemFacade($id);
232  }
if(!array_key_exists('StateId', $_REQUEST)) $id
getItemFacade(IdentificationInterface $identification=null)
Interface ilMMItemFacadeInterface.
+ Here is the call graph for this function:

◆ getPossibleParentsForFormAndTable()

ilMMItemRepository::getPossibleParentsForFormAndTable ( )

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

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

235  : array
236  {
237  static $parents;
238  if (is_null($parents)) {
239  $parents = [];
240  foreach ($this->getTopItems() as $top_item_identification => $data) {
241  $identification = $this->services->identification()->fromSerializedIdentification($top_item_identification);
242  $item = $this->getSingleItem($identification);
243  if ($item instanceof TopParentItem) {
244  $parents[$top_item_identification] = $this->getItemFacade($identification)
245  ->getDefaultTitle();
246  }
247  }
248  }
249 
250  return $parents;
251  }
getItemFacade(IdentificationInterface $identification=null)
getSingleItem(IdentificationInterface $identification)
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ getPossibleSubItemTypesForForm()

ilMMItemRepository::getPossibleSubItemTypesForForm ( )
Returns
array
See also
getPossibleSubItemTypesWithInformation
Deprecated:

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

260  : array
261  {
262  $types = [];
263  foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
264  if ($information->isCreationPrevented()) {
265  continue;
266  }
267  if ($information->isChild()) {
268  $types[$information->getType()] = $information->getTypeNameForPresentation();
269  }
270  }
271 
272  return $types;
273  }

◆ getPossibleSubItemTypesWithInformation()

ilMMItemRepository::getPossibleSubItemTypesWithInformation ( )
Returns
[]

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

279  : array
280  {
281  $types = [];
282  foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
283  if ($information->isCreationPrevented()) {
284  continue;
285  }
286  if ($information->isChild()) {
287  $types[$information->getType()] = $information;
288  }
289  }
290 
291  return $types;
292  }

◆ getPossibleTopItemTypesForForm()

ilMMItemRepository::getPossibleTopItemTypesForForm ( )
Returns
array
See also
getPossibleTopItemTypesWithInformation
Deprecated:

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

300  : array
301  {
302  $types = [];
303  foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
304  if ($information->isTop()) {
305  $types[$information->getType()] = $information->getTypeNameForPresentation();
306  }
307  }
308 
309  return $types;
310  }

◆ getPossibleTopItemTypesWithInformation()

ilMMItemRepository::getPossibleTopItemTypesWithInformation ( )
Returns
[]

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

316  : array
317  {
318  $types = [];
319  foreach ($this->main_collector->getTypeInformationCollection()->getAll() as $information) {
320  if ($information->isTop()) {
321  $types[$information->getType()] = $information;
322  }
323  }
324 
325  return $types;
326  }

◆ getSingleItem()

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

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

Referenced by getPossibleParentsForFormAndTable().

122  : isItem
123  {
124  return $this->main_collector->getSingleItem($identification);
125  }
+ Here is the caller graph for this function:

◆ getStackedTopItemsForPresentation()

ilMMItemRepository::getStackedTopItemsForPresentation ( )
Returns
TopLinkItem[]|TopParentItem[]
Exceptions
Throwable

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

108  : array
109  {
110  $top_items = $this->main_collector->getStackedTopItemsForPresentation();
111 
112  return $top_items;
113  }

◆ getSubItemsForTable()

ilMMItemRepository::getSubItemsForTable ( )
Returns
array

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

References $data, and $r.

Referenced by flushLostItems(), and hasLostItems().

150  : array
151  {
152  $r = $this->storage->db()->query(
153  "SELECT sub_items.*, top_items.position AS parent_position
154 FROM il_mm_items AS sub_items
155 LEFT JOIN il_mm_items AS top_items ON top_items.identification = sub_items.parent_identification
156 WHERE sub_items.parent_identification != '' ORDER BY top_items.position, parent_identification, sub_items.position ASC"
157  );
158  $return = [];
159  while ($data = $this->storage->db()->fetchAssoc($r)) {
160  $return[] = $data;
161  }
162 
163  return $return;
164  }
$r
Definition: example_031.php:79
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ getTopItems()

ilMMItemRepository::getTopItems ( )
Returns
array
Exceptions
arException

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

References ActiveRecord\where().

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

141  : array
142  {
143  return ilMMItemStorage::where(" parent_identification = '' OR parent_identification IS NULL ")->orderBy('position')->getArray();
144  }
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 336 of file class.ilMMItemRepository.php.

336  : TypeHandler
337  {
338  $item = $this->services->mainmenu()->custom($type, new NullIdentification());
339 
340  return $this->main_collector->getHandlerForItem($item);
341  }
$type

◆ hasLostItems()

ilMMItemRepository::hasLostItems ( )

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

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

183  : bool
184  {
185  foreach ($this->getTopItems() as $item) {
186  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
187  if (Lost::class === $item_facade->getType()) {
188  return true;
189  }
190  }
191 
192  foreach ($this->getSubItemsForTable() as $item) {
193  $item_facade = $this->getItemFacade($this->services->identification()->fromSerializedIdentification($item['identification']));
194  if (Lost::class === $item_facade->getType()) {
195  return true;
196  }
197  }
198  return false;
199  }
getItemFacade(IdentificationInterface $identification=null)
+ Here is the call graph for this function:

◆ repository()

ilMMItemRepository::repository ( )
Returns
ilMMItemRepository

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

132  {
133  return $this;
134  }
Class ilMMItemRepository.

◆ sync()

ilMMItemRepository::sync ( )
private

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

References PHPMailer\PHPMailer\$provider, $synced, ilPluginAdmin\getAllGlobalScreenProviders(), and ilGSIdentificationStorage\registerIdentification().

Referenced by __construct().

65  : bool
66  {
67  if ($this->synced === false || $this->synced === null) {
69  foreach ($provider->getAllIdentifications() as $identification) {
70  ilGSIdentificationStorage::registerIdentification($identification, $provider);
71  }
72  }
73 
74  $this->storage->db()->manipulate(
75  "DELETE FROM il_mm_items
76  WHERE EXISTS (SELECT null FROM il_gs_identifications
77  WHERE il_gs_identifications.identification = il_mm_items.identification
78  AND il_gs_identifications.identification IS NULL)"
79  );
80  $this->synced = true;
81  }
82 
83  return $this->synced;
84  }
static getAllGlobalScreenProviders()
static registerIdentification(\ILIAS\GlobalScreen\Identification\IdentificationInterface $identification, \ILIAS\GlobalScreen\Provider\Provider $provider)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateItem()

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

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

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

348  {
349  if ($item_facade->isEditable()) {
350  $item_facade->update();
351  $this->storage->cache()->flush();
352  }
353  }
+ Here is the call graph for this function:

Field Documentation

◆ $main_collector

ilMMItemRepository::$main_collector
private

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

◆ $services

ilMMItemRepository::$services
private

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

◆ $storage

ilMMItemRepository::$storage
private

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

◆ $synced

ilMMItemRepository::$synced = false
private

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

Referenced by sync().


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