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