ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilArtifactComponentRepository Class Reference

Repository for component data implemented over artifacts. More...

+ Inheritance diagram for ilArtifactComponentRepository:
+ Collaboration diagram for ilArtifactComponentRepository:

Public Member Functions

 __construct (Data\Factory $data_factory, ilPluginStateDB $plugin_state_db, Data\Version $ilias_version)
 
 hasComponent (string $type, string $name)
 
 hasComponentId (string $id)
 
 getComponents ()
 
 getComponentById (string $id)
 
 getComponentByTypeAndName (string $type, string $name)
 
 hasPluginSlotId (string $id)
 
 getPluginSlots ()
 
 getPluginSlotById (string $id)
 
 hasPluginId (string $id)
 Check if a plugin exists. More...
 
 getPlugins ()
 Get all plugins. More...
 
 getPluginById (string $id)
 Get a plugin by id. More...
 
 getPluginByName (string $name)
 Get a plugin by name. More...
 
 setCurrentPluginVersion (string $plugin_id, Data\Version $version, int $db_version)
 
 setActivation (string $plugin_id, bool $activated)
 
 removeStateInformationOf (string $plugin_id)
 
 hasActivatedPlugin (string $id)
 Check if a plugin exists and is activated. More...
 
- Public Member Functions inherited from ilComponentRepositoryWrite
 setCurrentPluginVersion (string $plugin_id, Version $version, int $db_version)
 

Data Fields

const COMPONENT_DATA_PATH = "Services/Component/artifacts/component_data.php"
 
const PLUGIN_DATA_PATH = "Services/Component/artifacts/plugin_data.php"
 
- Data Fields inherited from ilComponentRepository
const PLUGIN_BASE_PATH = "Customizing/global/plugins"
 

Protected Member Functions

 buildDatabase ()
 
 readComponentData ()
 
 readPluginData ()
 

Protected Attributes

Data Factory $data_factory
 
ilPluginStateDB $plugin_state_db
 
Data Version $ilias_version
 
array $components
 
array $component_id_by_type_and_name
 
array $pluginslot_by_id
 
array $plugin_by_id
 
array $plugin_by_name
 

Detailed Description

Repository for component data implemented over artifacts.

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

Constructor & Destructor Documentation

◆ __construct()

ilArtifactComponentRepository::__construct ( Data\Factory  $data_factory,
ilPluginStateDB  $plugin_state_db,
Data\Version  $ilias_version 
)

Definition at line 42 of file class.ilArtifactComponentRepository.php.

References $data_factory, $ilias_version, $plugin_state_db, and buildDatabase().

43  {
44  $this->data_factory = $data_factory;
45  $this->plugin_state_db = $plugin_state_db;
46  $this->ilias_version = $ilias_version;
47 
48  $this->buildDatabase();
49  }
+ Here is the call graph for this function:

Member Function Documentation

◆ buildDatabase()

ilArtifactComponentRepository::buildDatabase ( )
protected

Definition at line 51 of file class.ilArtifactComponentRepository.php.

References $data, $ilias_max_version, $ilias_min_version, $learning_progress, $responsible, $responsible_mail, $supports_export, $type, getComponentByTypeAndName(), hasComponent(), readComponentData(), and readPluginData().

Referenced by __construct(), removeStateInformationOf(), setActivation(), and setCurrentPluginVersion().

51  : void
52  {
53  $component_data = $this->readComponentData();
54  $plugin_data = $this->readPluginData();
55  $this->components = [];
56  $this->component_id_by_type_and_name = [
57  "Modules" => [],
58  "Services" => []
59  ];
60  $this->pluginslot_by_id = [];
61  $plugins_per_slot = [];
62  foreach ($component_data as $comp_id => [$type, $comp_name, $slot_data]) {
63  $slots = [];
64  $component = new ilComponentInfo(
65  $comp_id,
66  $type,
67  $comp_name,
68  $slots
69  );
70  foreach ($slot_data as [$slot_id, $slot_name]) {
71  $plugins_per_slot[$slot_id] = [];
72  $slots[$slot_id] = new ilPluginSlotInfo(
73  $component,
74  $slot_id,
75  $slot_name,
76  $plugins_per_slot[$slot_id]
77  );
78  $this->pluginslot_by_id[$slot_id] = $slots[$slot_id];
79  }
80  $this->components[$comp_id] = $component;
81  $this->component_id_by_type_and_name[$type][$comp_name] = $comp_id;
82  unset($slots);
83  }
84  $this->plugin_by_id = [];
85  foreach ($plugin_data as $plugin_id => $data) {
86  [
87  $type,
88  $comp_name,
89  $slot_name,
90  $plugin_name,
91  $plugin_version,
98  $supports_cli_setup
99  ] = $data;
100  if (!$this->hasComponent($type, $comp_name)) {
101  throw new \InvalidArgumentException(
102  "Can't find component $type/$comp_name for plugin $plugin_name"
103  );
104  }
105  $component = $this->getComponentByTypeAndName($type, $comp_name);
106  if (!$component->hasPluginSlotName($slot_name)) {
107  throw new \InvalidArgumentException(
108  "Can't find slot $type/$comp_name/$slot_name for plugin $plugin_name"
109  );
110  }
111  $slot = $component->getPluginSlotByName($slot_name);
112  $this->plugin_by_id[$plugin_id] = new ilPluginInfo(
113  $this->ilias_version,
114  $slot,
115  $plugin_id,
116  $plugin_name,
117  $this->plugin_state_db->isPluginActivated($plugin_id),
118  $this->plugin_state_db->getCurrentPluginVersion($plugin_id),
119  $this->plugin_state_db->getCurrentPluginDBVersion($plugin_id),
120  $this->data_factory->version($plugin_version),
121  $this->data_factory->version($ilias_min_version),
122  $this->data_factory->version($ilias_max_version),
123  $responsible,
125  $learning_progress ?? false,
126  $supports_export ?? false,
127  $supports_cli_setup ?? true
128  );
129  $plugins_per_slot[$slot->getId()][$plugin_id] = $this->plugin_by_id[$plugin_id];
130  }
131  }
$type
Simple value class for basic information about a pluginslot.
$ilias_max_version
Definition: plugin.php:26
$responsible
Definition: plugin.php:27
$learning_progress
Definition: plugin.php:29
$ilias_min_version
Definition: plugin.php:25
$responsible_mail
Definition: plugin.php:28
Simple value class for information about a plugin.
$supports_export
Definition: plugin.php:30
Simple value class for basic information about a component.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponentById()

ilArtifactComponentRepository::getComponentById ( string  $id)

Implements ilComponentRepository.

Definition at line 178 of file class.ilArtifactComponentRepository.php.

References $id, and hasComponentId().

179  {
180  if (!$this->hasComponentId($id)) {
181  throw new \InvalidArgumentException(
182  "Unknown component $id"
183  );
184  }
185  return $this->components[$id];
186  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Simple value class for basic information about a component.
+ Here is the call graph for this function:

◆ getComponentByTypeAndName()

ilArtifactComponentRepository::getComponentByTypeAndName ( string  $type,
string  $name 
)

Implements ilComponentRepository.

Definition at line 191 of file class.ilArtifactComponentRepository.php.

References $name, $type, and hasComponent().

Referenced by buildDatabase().

192  {
193  if (!$this->hasComponent($type, $name)) {
194  throw new \InvalidArgumentException(
195  "Unknown component $type/$name"
196  );
197  }
198  return $this->components[$this->component_id_by_type_and_name[$type][$name]];
199  }
$type
if($format !==null) $name
Definition: metadata.php:247
Simple value class for basic information about a component.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponents()

ilArtifactComponentRepository::getComponents ( )

Implements ilComponentRepository.

Definition at line 168 of file class.ilArtifactComponentRepository.php.

References $id.

168  : Iterator
169  {
170  foreach ($this->components as $id => $comp) {
171  yield $id => $comp;
172  }
173  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ getPluginById()

ilArtifactComponentRepository::getPluginById ( string  $id)

Get a plugin by id.

Exceptions

Implements ilComponentRepository.

Definition at line 260 of file class.ilArtifactComponentRepository.php.

References $id, and hasPluginId().

Referenced by hasActivatedPlugin(), and setCurrentPluginVersion().

260  : ilPluginInfo
261  {
262  if (!$this->hasPluginId($id)) {
263  throw new \InvalidArgumentException(
264  "Unknown plugin $id."
265  );
266  }
267  return $this->plugin_by_id[$id];
268  }
hasPluginId(string $id)
Check if a plugin exists.
Simple value class for information about a plugin.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPluginByName()

ilArtifactComponentRepository::getPluginByName ( string  $name)

Get a plugin by name.

Exceptions

Implements ilComponentRepository.

Definition at line 275 of file class.ilArtifactComponentRepository.php.

References $name, XapiProxy\$plugin, and getPlugins().

275  : ilPluginInfo
276  {
277  foreach ($this->getPlugins() as $plugin) {
278  if ($plugin->getName() === $name) {
279  return $plugin;
280  }
281  }
282  throw new \InvalidArgumentException(
283  "No plugin with name $name."
284  );
285  }
if($format !==null) $name
Definition: metadata.php:247
Simple value class for information about a plugin.
+ Here is the call graph for this function:

◆ getPlugins()

ilArtifactComponentRepository::getPlugins ( )

Get all plugins.

Keys are the ids.

Returns
Iterator <string, ilPluginInfo>

Implements ilComponentRepository.

Definition at line 248 of file class.ilArtifactComponentRepository.php.

References $id, and XapiProxy\$plugin.

Referenced by getPluginByName().

248  : Iterator
249  {
250  foreach ($this->plugin_by_id as $id => $plugin) {
251  yield $id => $plugin;
252  }
253  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ getPluginSlotById()

ilArtifactComponentRepository::getPluginSlotById ( string  $id)

Implements ilComponentRepository.

Definition at line 223 of file class.ilArtifactComponentRepository.php.

References $id, and hasPluginSlotId().

224  {
225  if (!$this->hasPluginSlotId($id)) {
226  throw new \InvalidArgumentException(
227  "Unknown pluginslot $id"
228  );
229  }
230  return $this->pluginslot_by_id[$id];
231  }
Simple value class for basic information about a pluginslot.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getPluginSlots()

ilArtifactComponentRepository::getPluginSlots ( )

Implements ilComponentRepository.

Definition at line 213 of file class.ilArtifactComponentRepository.php.

References $id.

213  : Iterator
214  {
215  foreach ($this->pluginslot_by_id as $id => $slot) {
216  yield $id => $slot;
217  }
218  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ hasActivatedPlugin()

ilArtifactComponentRepository::hasActivatedPlugin ( string  $id)

Check if a plugin exists and is activated.

Implements ilComponentRepository.

Definition at line 326 of file class.ilArtifactComponentRepository.php.

References getPluginById(), and hasPluginId().

326  : bool
327  {
328  return ($this->hasPluginId($id) && $this->getPluginById($id)->isActivated());
329  }
hasPluginId(string $id)
Check if a plugin exists.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ hasComponent()

ilArtifactComponentRepository::hasComponent ( string  $type,
string  $name 
)

Implements ilComponentRepository.

Definition at line 146 of file class.ilArtifactComponentRepository.php.

References ilComponentInfo\TYPES.

Referenced by buildDatabase(), and getComponentByTypeAndName().

146  : bool
147  {
148  if (!in_array($type, ilComponentInfo::TYPES)) {
149  throw new \InvalidArgumentException(
150  "Unknown component type $type."
151  );
152  }
153 
154  return isset($this->component_id_by_type_and_name[$type][$name]);
155  }
$type
if($format !==null) $name
Definition: metadata.php:247
+ Here is the caller graph for this function:

◆ hasComponentId()

ilArtifactComponentRepository::hasComponentId ( string  $id)

Implements ilComponentRepository.

Definition at line 160 of file class.ilArtifactComponentRepository.php.

Referenced by getComponentById().

160  : bool
161  {
162  return isset($this->components[$id]);
163  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ hasPluginId()

ilArtifactComponentRepository::hasPluginId ( string  $id)

Check if a plugin exists.

Implements ilComponentRepository.

Definition at line 236 of file class.ilArtifactComponentRepository.php.

Referenced by getPluginById(), hasActivatedPlugin(), removeStateInformationOf(), and setActivation().

236  : bool
237  {
238  return isset($this->plugin_by_id[$id]);
239  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ hasPluginSlotId()

ilArtifactComponentRepository::hasPluginSlotId ( string  $id)

Implements ilComponentRepository.

Definition at line 205 of file class.ilArtifactComponentRepository.php.

Referenced by getPluginSlotById().

205  : bool
206  {
207  return isset($this->pluginslot_by_id[$id]);
208  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ readComponentData()

ilArtifactComponentRepository::readComponentData ( )
protected

Definition at line 133 of file class.ilArtifactComponentRepository.php.

Referenced by buildDatabase().

133  : array
134  {
135  return require self::COMPONENT_DATA_PATH;
136  }
+ Here is the caller graph for this function:

◆ readPluginData()

ilArtifactComponentRepository::readPluginData ( )
protected

Definition at line 138 of file class.ilArtifactComponentRepository.php.

Referenced by buildDatabase().

138  : array
139  {
140  return require self::PLUGIN_DATA_PATH;
141  }
+ Here is the caller graph for this function:

◆ removeStateInformationOf()

ilArtifactComponentRepository::removeStateInformationOf ( string  $plugin_id)

Implements ilComponentRepositoryWrite.

Definition at line 315 of file class.ilArtifactComponentRepository.php.

References buildDatabase(), and hasPluginId().

315  : void
316  {
317  if (!$this->hasPluginId($plugin_id)) {
318  throw new \InvalidArgumentException(
319  "Unknown plugin $plugin_id."
320  );
321  }
322  $this->plugin_state_db->remove($plugin_id);
323  $this->buildDatabase();
324  }
hasPluginId(string $id)
Check if a plugin exists.
+ Here is the call graph for this function:

◆ setActivation()

ilArtifactComponentRepository::setActivation ( string  $plugin_id,
bool  $activated 
)

Implements ilComponentRepositoryWrite.

Definition at line 304 of file class.ilArtifactComponentRepository.php.

References buildDatabase(), and hasPluginId().

304  : void
305  {
306  if (!$this->hasPluginId($plugin_id)) {
307  throw new \InvalidArgumentException(
308  "Unknown plugin $plugin_id."
309  );
310  }
311  $this->plugin_state_db->setActivation($plugin_id, $activated);
312  $this->buildDatabase();
313  }
hasPluginId(string $id)
Check if a plugin exists.
+ Here is the call graph for this function:

◆ setCurrentPluginVersion()

ilArtifactComponentRepository::setCurrentPluginVersion ( string  $plugin_id,
Data\Version  $version,
int  $db_version 
)

Definition at line 287 of file class.ilArtifactComponentRepository.php.

References XapiProxy\$plugin, buildDatabase(), and getPluginById().

287  : void
288  {
289  $plugin = $this->getPluginById($plugin_id);
290  if ($plugin->getCurrentVersion() !== null && $plugin->getCurrentVersion()->isGreaterThan($version)) {
291  throw new \RuntimeException(
292  "Cannot downgrade plugins version from {$plugin->getCurrentVersion()} to $version"
293  );
294  }
295  if ($plugin->getCurrentDBVersion() !== null && $plugin->getCurrentDBVersion() > $db_version) {
296  throw new \RuntimeException(
297  "Cannot downgrade plugins db version from {$plugin->getCurrentDBVersion()} to $db_version"
298  );
299  }
300  $this->plugin_state_db->setCurrentPluginVersion($plugin_id, $version, $db_version);
301  $this->buildDatabase();
302  }
$version
Definition: plugin.php:24
+ Here is the call graph for this function:

Field Documentation

◆ $component_id_by_type_and_name

array ilArtifactComponentRepository::$component_id_by_type_and_name
protected

Definition at line 37 of file class.ilArtifactComponentRepository.php.

◆ $components

array ilArtifactComponentRepository::$components
protected

Definition at line 36 of file class.ilArtifactComponentRepository.php.

◆ $data_factory

Data Factory ilArtifactComponentRepository::$data_factory
protected

Definition at line 32 of file class.ilArtifactComponentRepository.php.

Referenced by __construct().

◆ $ilias_version

Data Version ilArtifactComponentRepository::$ilias_version
protected

Definition at line 34 of file class.ilArtifactComponentRepository.php.

Referenced by __construct().

◆ $plugin_by_id

array ilArtifactComponentRepository::$plugin_by_id
protected

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

◆ $plugin_by_name

array ilArtifactComponentRepository::$plugin_by_name
protected

Definition at line 40 of file class.ilArtifactComponentRepository.php.

◆ $plugin_state_db

ilPluginStateDB ilArtifactComponentRepository::$plugin_state_db
protected

Definition at line 33 of file class.ilArtifactComponentRepository.php.

Referenced by __construct().

◆ $pluginslot_by_id

array ilArtifactComponentRepository::$pluginslot_by_id
protected

Definition at line 38 of file class.ilArtifactComponentRepository.php.

◆ COMPONENT_DATA_PATH

const ilArtifactComponentRepository::COMPONENT_DATA_PATH = "Services/Component/artifacts/component_data.php"

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

◆ PLUGIN_DATA_PATH

const ilArtifactComponentRepository::PLUGIN_DATA_PATH = "Services/Component/artifacts/plugin_data.php"

Definition at line 30 of file class.ilArtifactComponentRepository.php.


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