ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilComponentDefinitionReader Class Reference
+ Collaboration diagram for ilComponentDefinitionReader:

Public Member Functions

 __construct (ilComponentDefinitionProcessor ... $processor)
 
 purge ()
 This methods is supposed to purge existing data in the registered processor. More...
 
 readComponentDefinitions ()
 This reads the component.xml of all components in the core and processes them with the provided processor. More...
 
 beginTag ($_, string $name, array $attributes)
 
 endTag ($_, string $name)
 

Protected Member Functions

 readFile (string $path)
 
 parseComponentXML (string $type, string $component, string $xml)
 
 getComponents ()
 
 getComponentInfo (string $type, string $name)
 
 getComponentPaths (string $root, string $name)
 

Protected Attributes

array $processors
 

Detailed Description

Definition at line 22 of file class.ilComponentDefinitionReader.php.

Constructor & Destructor Documentation

◆ __construct()

ilComponentDefinitionReader::__construct ( ilComponentDefinitionProcessor ...  $processor)

Definition at line 29 of file class.ilComponentDefinitionReader.php.

31  {
32  $this->processors = $processor;
33  }

Member Function Documentation

◆ beginTag()

ilComponentDefinitionReader::beginTag (   $_,
string  $name,
array  $attributes 
)

Definition at line 98 of file class.ilComponentDefinitionReader.php.

98  : void
99  {
100  foreach ($this->processors as $processor) {
101  $processor->beginTag($name, $attributes);
102  }
103  }

◆ endTag()

ilComponentDefinitionReader::endTag (   $_,
string  $name 
)

Definition at line 105 of file class.ilComponentDefinitionReader.php.

105  : void
106  {
107  foreach ($this->processors as $processor) {
108  $processor->endTag($name);
109  }
110  }

◆ getComponentInfo()

ilComponentDefinitionReader::getComponentInfo ( string  $type,
string  $name 
)
protected
Returns
Iterator<array>

Definition at line 128 of file class.ilComponentDefinitionReader.php.

References $c, and getComponentPaths().

Referenced by getComponents().

128  : \Iterator
129  {
130  $dir = __DIR__ . "/../../../../" . $type;
131  foreach ($this->getComponentPaths($dir, $name) as $c) {
132  yield [
133  $type,
134  $c,
135  realpath($dir . "/" . $c . "/" . $name)
136  ];
137  }
138  }
$c
Definition: deliver.php:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponentPaths()

ilComponentDefinitionReader::getComponentPaths ( string  $root,
string  $name 
)
protected
Returns
Iterator<string>

Definition at line 143 of file class.ilComponentDefinitionReader.php.

Referenced by getComponentInfo().

143  : \Iterator
144  {
145  $dir = opendir($root);
146  while ($sub = readdir($dir)) {
147  if ($sub === "." || $sub === "..") {
148  continue;
149  }
150  if (!is_dir($root . "/" . $sub)) {
151  continue;
152  }
153  if (!is_file($root . "/" . $sub . "/" . $name)) {
154  continue;
155  }
156  yield $sub;
157  }
158  }
+ Here is the caller graph for this function:

◆ getComponents()

ilComponentDefinitionReader::getComponents ( )
protected
Returns
Iterator<string>

Definition at line 115 of file class.ilComponentDefinitionReader.php.

References getComponentInfo().

Referenced by readComponentDefinitions().

115  : \Iterator
116  {
117  foreach ($this->getComponentInfo("components/ILIAS", "module.xml") as $i) {
118  yield $i;
119  }
120  foreach ($this->getComponentInfo("components/ILIAS", "service.xml") as $i) {
121  yield $i;
122  }
123  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseComponentXML()

ilComponentDefinitionReader::parseComponentXML ( string  $type,
string  $component,
string  $xml 
)
protected

Definition at line 74 of file class.ilComponentDefinitionReader.php.

Referenced by readComponentDefinitions().

74  : void
75  {
76  $xml_parser = null;
77  try {
78  $xml_parser = xml_parser_create("UTF-8");
79  xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
80  xml_set_object($xml_parser, $this);
81  xml_set_element_handler($xml_parser, 'beginTag', 'endTag');
82  if (!xml_parse($xml_parser, $xml)) {
83  $code = xml_get_error_code($xml_parser);
84  $line = xml_get_current_line_number($xml_parser);
85  $col = xml_get_current_column_number($xml_parser);
86  $msg = xml_error_string($code);
87  throw new \InvalidArgumentException(
88  "Error $code component xml of $type/$component, on line $line in column $col: $msg"
89  );
90  }
91  } finally {
92  if ($xml_parser) {
93  xml_parser_free($xml_parser);
94  }
95  }
96  }
+ Here is the caller graph for this function:

◆ purge()

ilComponentDefinitionReader::purge ( )

This methods is supposed to purge existing data in the registered processor.

Definition at line 39 of file class.ilComponentDefinitionReader.php.

39  : void
40  {
41  foreach ($this->processors as $p) {
42  $p->purge();
43  }
44  }

◆ readComponentDefinitions()

ilComponentDefinitionReader::readComponentDefinitions ( )

This reads the component.xml of all components in the core and processes them with the provided processor.

Definition at line 50 of file class.ilComponentDefinitionReader.php.

References $path, getComponents(), parseComponentXML(), and readFile().

50  : void
51  {
52  foreach ($this->getComponents() as [$type, $component, $path]) {
53  $file = $this->readFile($path);
54  foreach ($this->processors as $processor) {
55  $processor->beginComponent($component, $type);
56  }
57  $this->parseComponentXML($type, $component, $file);
58  foreach ($this->processors as $processor) {
59  $processor->endComponent($component, $type);
60  }
61  }
62  }
parseComponentXML(string $type, string $component, string $xml)
$path
Definition: ltiservices.php:30
+ Here is the call graph for this function:

◆ readFile()

ilComponentDefinitionReader::readFile ( string  $path)
protected

Definition at line 64 of file class.ilComponentDefinitionReader.php.

Referenced by readComponentDefinitions().

64  : string
65  {
66  if (!file_exists($path)) {
67  throw new \InvalidArgumentException(
68  "Cannot find file $path."
69  );
70  }
71  return file_get_contents($path);
72  }
$path
Definition: ltiservices.php:30
+ Here is the caller graph for this function:

Field Documentation

◆ $processors

array ilComponentDefinitionReader::$processors
protected

Definition at line 27 of file class.ilComponentDefinitionReader.php.


The documentation for this class was generated from the following file: