ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
FactoriesCrawler.php
Go to the documentation of this file.
1<?php
2/***
3 * @author Timon Amstutz <timon.amstutz@ilub.unibe.ch>
4 * @version $Id$
5 *
6 */
8
9use Symfony\Component\Yaml;
11
12class FactoriesCrawler implements Crawler
13{
17 protected $parser = null;
18
22 protected $ef = null;
23
27 public function __construct()
28 {
29 $this->parser = new EntriesYamlParser();
30 $this->ef = new Exception\Factory();
31 }
32
36 public function crawlFactory($factoryPath, Entry\ComponentEntry $parent = null, $depth = 0)
37 {
38 $depth++;
39 if ($depth > 30) {
40 throw $this->ef->exception(Exception\CrawlerException::CRAWL_MAX_NESTING_REACHED, " Current Path: " . $factoryPath . " Parent: " . $parent->getId());
41 }
42 $entries = $this->parser->parseEntriesFromFile($factoryPath);
43
44 $children = new Entry\ComponentEntries();
45
46 foreach ($entries as $entry) {
47 if ($entry->isAbstract()) {
48 $children->addEntries($this->crawlFactory($entry->getPath() . ".php", $entry, $depth));
49 }
50 if ($parent) {
51 $entry->setParent($parent->getId());
52 $parent->addChild($entry->getId());
53 }
54 }
55 $entries->addEntries($children);
56 return $entries;
57 }
58}
An exception for terminatinating execution or to throw for unit testing.
Container storing a list of UI Component Entries, can act as Iterator, countable and is serializable.
crawlFactory($factoryPath, Entry\ComponentEntry $parent=null, $depth=0)
Starts with the factory indicated by factory path and crawles form this point all all subsequent fact...