ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilEventHandlingBuildEventInfoObjective.php
Go to the documentation of this file.
1 <?php
2 
19 use ILIAS\Setup;
20 
21 class ilEventHandlingBuildEventInfoObjective extends Setup\Artifact\BuildArtifactObjective
22 {
24 
25  public function getArtifactPath(): string
26  {
27  return \ilArtifactEventHandlingData::EVENT_HANDLING_DATA_PATH;
28  }
29 
30  public function getPreconditions(Setup\Environment $environment): array
31  {
32  return [
34  ];
35  }
36 
37  public function achieve(Setup\Environment $environment): Setup\Environment
38  {
39  $this->component_repository = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_REPOSITORY);
40 
41  return parent::achieve($environment);
42  }
43 
44  public function build(): Setup\Artifact
45  {
46  $processor = new \ilEventHandlingDefinitionProcessor();
47 
48  // Plugins behave slightly differently from core components: they do not always have a plugin.xml and the
49  // `ilComponentDefinitionReader` does not read them at all. Therefore, we overwrite the reader at this point
50  // and supplement it with the information from the existing plugins.
51 
52  $plugin_and_components_reader = new class ($this->component_repository, $processor) extends
54  public function __construct(
55  private ilComponentRepository $component_repository,
56  ilComponentDefinitionProcessor ...$processor,
57  ) {
58  parent::__construct(...$processor);
59  }
60 
61  protected function getComponents(): \Iterator
62  {
63  yield from parent::getComponents();
64 
65  foreach ($this->component_repository->getPlugins() as $plugin) {
66  $xml_plugin_path = $plugin->getPath() . '/plugin.xml';
67  if (!file_exists($xml_plugin_path)) {
68  continue;
69  }
70  yield [
71  'Plugins', // Plugins are generally handled in ilAppEventHandler with the prefix "Plugins".
72  $plugin->getName(),
73  $xml_plugin_path,
74  ];
75  }
76  }
77  };
78 
79  $plugin_and_components_reader->purge();
80  $plugin_and_components_reader->readComponentDefinitions();
81 
82  return new Setup\Artifact\ArrayArtifact($processor->getData());
83  }
84 }
Readable part of repository interface to ilComponentDataDB.
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i.e.
__construct(VocabulariesInterface $vocabularies)
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
An artifact is some file that is build on demand per installation and is not shipped with the ILIAS s...
Definition: Artifact.php:27