ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilComponentInfoDefinitionProcessor.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected array $data = [];
24 protected array $slots = [];
25 protected ?string $component_id;
26 protected ?string $component;
27 protected ?string $type;
28
29 public function getData(): array
30 {
31 return $this->data;
32 }
33
34 public function purge(): void
35 {
36 $this->data = [];
37 $this->slots = [];
38 }
39
40 public function beginComponent(string $component, string $type): void
41 {
42 $this->component_id = null;
43 $this->component = $component;
44 $this->type = $type;
45 }
46
47 public function endComponent(string $component, string $type): void
48 {
49 $this->component_id = null;
50 $this->component = null;
51 $this->type = null;
52 }
53
54 public function beginTag(string $name, array $attributes): void
55 {
56 if ($name === "module") {
57 $type = "components/ILIAS";
58 } elseif ($name === "service") {
59 $type = "components/ILIAS";
60 } elseif ($name === "pluginslot") {
61 $type = null;
62 } else {
63 return;
64 }
65
66 if (!isset($attributes["id"])) {
67 throw new \InvalidArgumentException(
68 "Expected attribute 'id' for tag '$name' in $this->component"
69 );
70 }
71
72 $id = $attributes["id"];
73 if (!is_null($type)) {
74 if ($type !== $this->type) {
75 throw new \InvalidArgumentException(
76 "Type $this->type and tag don't match for component $this->component"
77 );
78 }
79 if (isset($this->data[$id])) {
80 throw new \LogicException(
81 "In $this->type/$this->component: Id '$id' for component is used twice. First occurence was in {$this->data[$id][0]}/{$this->data[$id][1]}."
82 );
83 }
84 $this->component_id = $id;
85 $this->data[$id] = [$this->type, $this->component, []];
86 } else {
87 if (!isset($attributes["name"])) {
88 throw new \InvalidArgumentException(
89 "Expected attribute 'name' for tag '$name' in $this->component"
90 );
91 }
92 if (isset($this->slots[$id])) {
93 throw new \LogicException(
94 "In $this->type/$this->component: Id '$id' for plugin slot is used twice. First occurence was in {$this->slots[$id][0]}/{$this->slots[$id][1]}."
95 );
96 }
97 $this->slots[$id] = [$this->type, $this->component];
98 $this->data[$this->component_id][2][] = [$id, $attributes["name"]];
99 }
100 }
101
102 public function endTag(string $name): void
103 {
104 }
105}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
endComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component ends.
beginTag(string $name, array $attributes)
This is called when a tag starts in the context of the given component.
beginComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component starts.
endTag(string $name)
This is called when a tag ends in the context of the given component.
purge()
This methods is supposed to purge existing data in the provider of the component, so new components c...
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i....