ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
FactoriesCrawler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
25/***
26 * @author Timon Amstutz <timon.amstutz@ilub.unibe.ch>
27 * @version $Id$
28 */
29class FactoriesCrawler implements Crawler
30{
31 protected ?EntriesYamlParser $parser = null;
32 protected ?Exception\Factory $ef = null;
33
34 public function __construct()
35 {
36 $this->parser = new EntriesYamlParser();
37 $this->ef = new Exception\Factory();
38 }
39
43 public function crawlFactory(
44 string $factoryPath,
45 ?Entry\ComponentEntry $parent = null,
46 int $depth = 0
47 ): Entry\ComponentEntries {
48 $depth++;
49 if ($depth > 30) {
50 throw $this->ef->exception(Exception\CrawlerException::CRAWL_MAX_NESTING_REACHED, " Current Path: " . $factoryPath . " Parent: " . $parent->getId());
51 }
52 $entries = $this->parser->parseEntriesFromFile($factoryPath);
53
54 $children = new Entry\ComponentEntries();
55
56 foreach ($entries as $entry) {
57 if ($entry->isAbstract()) {
58 $children->addEntries($this->crawlFactory($entry->getPath() . ".php", $entry, $depth));
59 }
60 if ($parent) {
61 $entry->setParent($parent->getId());
62 $parent->addChild($entry->getId());
63 }
64 }
65 $entries->addEntries($children);
66 return $entries;
67 }
68}
Container storing a list of UI Component Entries, can act as Iterator, countable and is serializable.
crawlFactory(string $factoryPath, ?Entry\ComponentEntry $parent=null, int $depth=0)
Starts with the factory indicated by factory path and crawles form this point all subsequent factorie...