ILIAS  release_7 Revision v7.30-3-g800a261c036
JsCollection.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
21
27{
31 protected $path_storage = [];
32
36 public function addItem(Js $item) : void
37 {
38 $basename = $this->stripPath($item->getContent());
39 if (!array_key_exists($basename, $this->items)) {
40 $this->storeItem($item);
41 } else {
42 $existing = $this->items[$basename];
43 if (($existing instanceof Js) && $existing->getBatch() > $item->getBatch()) {
44 $this->storeItem($item);
45 }
46 }
47 }
48
49 private function storeItem(
50 js $item
51 ) : void {
52 $strip_path = $this->stripPath($item->getContent());
53 $this->items[$strip_path] = $item;
54 $this->path_storage[$strip_path] = $item->getBatch();
55 }
56
60 public function getItemsInOrderOfDelivery() : array
61 {
62 $ordered = [];
63 foreach ($this->getItems() as $js) {
64 $ordered['pos_' . (string) $js->getBatch()][] = $js;
65 }
66 ksort($ordered);
67 $ordered_all = [];
68 foreach ($ordered as $item) {
69 foreach ($item as $js) {
70 $ordered_all[] = $js;
71 }
72 }
73
74 return $ordered_all;
75 }
76}
An exception for terminatinating execution or to throw for unit testing.