ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
JsCollection.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
21 
27 {
28  protected array $path_storage = [];
29 
33  public function addItem(Js $item): void
34  {
35  $basename = $this->stripPath($item->getContent());
36  if (!array_key_exists($basename, $this->items)) {
37  $this->storeItem($item);
38  } else {
39  $existing = $this->items[$basename];
40  if (($existing instanceof Js) && $existing->getBatch() > $item->getBatch()) {
41  $this->storeItem($item);
42  }
43  }
44  }
45 
46  private function storeItem(
47  js $item
48  ): void {
49  $strip_path = $this->stripPath($item->getContent());
50  $this->items[$strip_path] = $item;
51  $this->path_storage[$strip_path] = $item->getBatch();
52  }
53 
57  public function getItemsInOrderOfDelivery(): array
58  {
59  $ordered = [];
60  foreach ($this->getItems() as $js) {
61  $ordered['pos_' . (string) $js->getBatch()][] = $js;
62  }
63  ksort($ordered);
64  $ordered_all = [];
65  foreach ($ordered as $item) {
66  foreach ($item as $js) {
67  $ordered_all[] = $js;
68  }
69  }
70 
71  return $ordered_all;
72  }
73 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...