ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CssCollection.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27{
28 public function addItem(Css $item): void
29 {
30 $content = $item->getContent();
31
32 // Add external URLs to the collection if allowed
33 if ($this->allow_external && $this->isExternalURI($content)) {
34 $this->items[] = $item;
35 return;
36 }
37
38 if ($this->isURI($content)) {
39 $this->items[] = $item;
40 return;
41 }
42
43 // add item only if it is not already in the collection
44 $real_path = realpath(parse_url($content, PHP_URL_PATH));
45 if (!$this->allow_non_existing && $real_path === false) {
46 return;
47 }
48 foreach ($this->getItems() as $css) {
49 if (!$this->allow_non_existing && realpath(parse_url((string) $css->getContent(), PHP_URL_PATH)) === $real_path) {
50 return;
51 }
52 }
53 $this->items[] = $item;
54 }
55
56}