19declare(strict_types=1);
31 $this->processors = $processor;
40 foreach ($this->processors as $p) {
53 foreach ($this->processors as $processor) {
54 $processor->beginComponent($component, $type);
57 foreach ($this->processors as $processor) {
58 $processor->endComponent($component, $type);
65 if (!file_exists(
$path)) {
66 throw new \InvalidArgumentException(
67 "Cannot find file $path."
70 return file_get_contents(
$path);
75 $xml_parser = xml_parser_create(
"UTF-8");
76 xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING,
false);
77 xml_set_element_handler($xml_parser, $this->
beginTag(...), $this->
endTag(...));
78 if (!xml_parse($xml_parser, $xml)) {
79 $code = xml_get_error_code($xml_parser);
80 $line = xml_get_current_line_number($xml_parser);
81 $col = xml_get_current_column_number($xml_parser);
82 $msg = xml_error_string($code);
83 throw new \InvalidArgumentException(
84 "Error $code component xml of $type/$component, on line $line in column $col: $msg"
89 public function beginTag($_,
string $name, array $attributes): void
91 foreach ($this->processors as $processor) {
92 $processor->beginTag($name, $attributes);
96 public function endTag($_,
string $name): void
98 foreach ($this->processors as $processor) {
99 $processor->endTag($name);
108 foreach (glob(
"components/*") as $component_namespace) {
109 $short_namespace = basename($component_namespace);
110 foreach ($this->
getComponentInfo(
"components/" . $short_namespace,
"module.xml") as $i) {
113 foreach ($this->
getComponentInfo(
"components/" . $short_namespace,
"service.xml") as $i) {
116 foreach ($this->
getComponentInfo(
"components/" . $short_namespace,
"component.xml") as $i) {
127 $dir = __DIR__ .
"/../../../../" . $type;
132 realpath($dir .
"/" .
$c .
"/" . $name)
142 $dir = opendir($root);
143 while ($sub = readdir($dir)) {
144 if ($sub ===
"." || $sub ===
"..") {
147 if (!is_dir($root .
"/" . $sub)) {
150 if (!is_file($root .
"/" . $sub .
"/" . $name)) {
getComponentPaths(string $root, string $name)
beginTag($_, string $name, array $attributes)
readComponentDefinitions()
This reads the component.xml of all components in the core and processes them with the provided proce...
__construct(ilComponentDefinitionProcessor ... $processor)
getComponentInfo(string $type, string $name)
purge()
This methods is supposed to purge existing data in the registered processor.
parseComponentXML(string $type, string $component, string $xml)
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i....