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