ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
JsCollection.php
Go to the documentation of this file.
2
3/******************************************************************************
4 * This file is part of ILIAS, a powerful learning management system.
5 * ILIAS is licensed with the GPL-3.0, you should have received a copy
6 * of said license along with the source code.
7 * If this is not the case or you just want to try ILIAS, you'll find
8 * us at:
9 * https://www.ilias.de
10 * https://github.com/ILIAS-eLearning
11 *****************************************************************************/
12
19{
20
24 protected $path_storage = [];
25
26
30 public function addItem(Js $item)
31 {
32 $basename = $this->stripPath($item->getContent());
33 if (!array_key_exists($basename, $this->items)) {
34 $this->storeItem($item);
35 } else {
36 $existing = $this->items[$basename];
37 if (($existing instanceof Js) && $existing->getBatch() > $item->getBatch()) {
38 $this->storeItem($item);
39 }
40 }
41 }
42
43
44 private function storeItem(
45 js $item
46 ) {
47 $strip_path = $this->stripPath($item->getContent());
48 $this->items[$strip_path] = $item;
49 $this->path_storage[$strip_path] = $item->getBatch();
50 }
51
52
56 public function getItemsInOrderOfDelivery() : array
57 {
58 $ordered = [];
59 foreach ($this->getItems() as $js) {
60 $ordered['pos_' . (string) $js->getBatch()][] = $js;
61 }
62 ksort($ordered);
63 $ordered_all = [];
64 foreach ($ordered as $item) {
65 foreach ($item as $js) {
66 $ordered_all[] = $js;
67 }
68 }
69
70 return $ordered_all;
71 }
72}
An exception for terminatinating execution or to throw for unit testing.