ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 @inheritdocs More...
 
 hasComponentId (string $id)
 @inheritdocs More...
 
 getComponents ()
 @inheritdocs More...
 
 getComponentById (string $id)
 @inheritdocs More...
 
 getComponentByTypeAndName (string $type, string $name)
 @inheritdocs More...
 
 hasPluginSlotId (string $id)
 @inheritdocs More...
 
 getPluginSlots ()
 @inheritdocs More...
 
 getPluginSlotById (string $id)
 @inheritdocs More...
 
 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)
 
 setActivation (string $plugin_id, bool $activated)
 
 removeStateInformationOf (string $plugin_id)
 
 hasComponent (string $type, string $name)
 Check if a component exists. More...
 
 hasComponentId (string $id)
 Check if a component exists. More...
 
 getComponents ()
 Get all components. More...
 
 getComponentById (string $id)
 Get a component by id. More...
 
 getComponentByTypeAndName (string $type, string $name)
 Get a component by type and name. More...
 
 hasPluginSlotId (string $id)
 Check if a slot exists. More...
 
 getPluginSlots ()
 Get all pluginslots. More...
 
 getPluginSlotById (string $id)
 Get pluginslot by id. More...
 
 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...
 
 hasActivatedPlugin (string $id)
 Check if a plugin exists and is activated. More...
 

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
 

Additional Inherited Members

- Data Fields inherited from ilComponentRepository
const PLUGIN_BASE_PATH = __DIR__ . '/../../../../public/Customizing/global/plugins'
 

Detailed Description

Repository for component data implemented over artifacts.

Definition at line 26 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 38 of file class.ilArtifactComponentRepository.php.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildDatabase()

ilArtifactComponentRepository::buildDatabase ( )
protected

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

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

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponentById()

ilArtifactComponentRepository::getComponentById ( string  $id)

@inheritdocs

Implements ilComponentRepository.

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

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

References $id, and hasComponentId().

+ Here is the call graph for this function:

◆ getComponentByTypeAndName()

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

@inheritdocs

Implements ilComponentRepository.

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

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 }

References hasComponent().

Referenced by buildDatabase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponents()

ilArtifactComponentRepository::getComponents ( )

@inheritdocs

Implements ilComponentRepository.

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

168 : Iterator
169 {
170 foreach ($this->components as $id => $comp) {
171 yield $id => $comp;
172 }
173 }

References $id.

◆ getPluginById()

ilArtifactComponentRepository::getPluginById ( string  $id)

Get a plugin by id.

Exceptions

InvalidArgumentException if plugin does not exist

Implements ilComponentRepository.

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

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.

References $id, and hasPluginId().

Referenced by hasActivatedPlugin(), setCurrentPluginVersion(), and ilArtifactComponentRepositoryTest\testUsesPluginStateDB().

+ 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

InvalidArgumentException if plugin does not exist

Implements ilComponentRepository.

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

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 }

References XapiProxy\$plugin, and getPlugins().

+ 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.

248 : Iterator
249 {
250 foreach ($this->plugin_by_id as $id => $plugin) {
251 yield $id => $plugin;
252 }
253 }

References $id, and XapiProxy\$plugin.

Referenced by getPluginByName().

+ Here is the caller graph for this function:

◆ getPluginSlotById()

ilArtifactComponentRepository::getPluginSlotById ( string  $id)

@inheritdocs

Implements ilComponentRepository.

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

224 {
225 if (!$this->hasPluginSlotId($id)) {
226 throw new \InvalidArgumentException(
227 "Unknown pluginslot $id"
228 );
229 }
230 return $this->pluginslot_by_id[$id];
231 }

References $id, and hasPluginSlotId().

+ Here is the call graph for this function:

◆ getPluginSlots()

ilArtifactComponentRepository::getPluginSlots ( )

@inheritdocs

Implements ilComponentRepository.

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

213 : Iterator
214 {
215 foreach ($this->pluginslot_by_id as $id => $slot) {
216 yield $id => $slot;
217 }
218 }

References $id.

Referenced by ilArtifactComponentRepositoryTest\testNoPluginSlot().

+ Here is the caller graph for this function:

◆ hasActivatedPlugin()

ilArtifactComponentRepository::hasActivatedPlugin ( string  $id)

Check if a plugin exists and is activated.

Implements ilComponentRepository.

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

326 : bool
327 {
328 return ($this->hasPluginId($id) && $this->getPluginById($id)->isActivated());
329 }

References getPluginById(), and hasPluginId().

+ Here is the call graph for this function:

◆ hasComponent()

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

@inheritdocs

Implements ilComponentRepository.

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

144 : bool
145 {
146 $types = ilComponentInfo::TYPES;
149 if (!in_array($type, $types)) {
150 throw new \InvalidArgumentException(
151 "Unknown component type $type."
152 );
153 }
154 return isset($this->component_id_by_type_and_name[$type][$name]);
155 }

References ilComponentInfo\TYPE_MODULES, ilComponentInfo\TYPE_SERVICES, and ilComponentInfo\TYPES.

Referenced by buildDatabase(), and getComponentByTypeAndName().

+ Here is the caller graph for this function:

◆ hasComponentId()

ilArtifactComponentRepository::hasComponentId ( string  $id)

@inheritdocs

Implements ilComponentRepository.

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

160 : bool
161 {
162 return isset($this->components[$id]);
163 }

Referenced by getComponentById().

+ 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.

236 : bool
237 {
238 return isset($this->plugin_by_id[$id]);
239 }

References $id.

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

+ Here is the caller graph for this function:

◆ hasPluginSlotId()

ilArtifactComponentRepository::hasPluginSlotId ( string  $id)

@inheritdocs

Implements ilComponentRepository.

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

205 : bool
206 {
207 return isset($this->pluginslot_by_id[$id]);
208 }

References $id.

Referenced by getPluginSlotById().

+ Here is the caller graph for this function:

◆ readComponentData()

ilArtifactComponentRepository::readComponentData ( )
protected

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

131 : array
132 {
133 return require ilComponentBuildComponentInfoObjective::PATH();
134 }

Referenced by buildDatabase().

+ Here is the caller graph for this function:

◆ readPluginData()

ilArtifactComponentRepository::readPluginData ( )
protected

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

136 : array
137 {
138 return require ilComponentBuildPluginInfoObjective::PATH();
139 }

Referenced by buildDatabase().

+ 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.

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 }

References buildDatabase(), and hasPluginId().

Referenced by ilArtifactComponentRepositoryTest\testRemoveStateInformationOfCallsStateDB(), and ilArtifactComponentRepositoryTest\testRemoveStateInformationOfTriggersRebuild().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActivation()

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

Implements ilComponentRepositoryWrite.

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

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 }

References buildDatabase(), and hasPluginId().

Referenced by ilArtifactComponentRepositoryTest\testSetActivationCallsStateDB(), and ilArtifactComponentRepositoryTest\testSetActivationTriggersRebuild().

+ Here is the call graph for this function:
+ Here is the caller 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.

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

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

Referenced by ilArtifactComponentRepositoryTest\testSetCurrentPluginVersionCallsStateDB(), and ilArtifactComponentRepositoryTest\testSetCurrentPluginVersionCallsStateDBTriggersRebuild().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $component_id_by_type_and_name

array ilArtifactComponentRepository::$component_id_by_type_and_name
protected

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

◆ $components

array ilArtifactComponentRepository::$components
protected

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

◆ $data_factory

Data Factory ilArtifactComponentRepository::$data_factory
protected

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

Referenced by __construct().

◆ $ilias_version

Data Version ilArtifactComponentRepository::$ilias_version
protected

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

Referenced by __construct().

◆ $plugin_by_id

array ilArtifactComponentRepository::$plugin_by_id
protected

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

◆ $plugin_by_name

array ilArtifactComponentRepository::$plugin_by_name
protected

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

◆ $plugin_state_db

ilPluginStateDB ilArtifactComponentRepository::$plugin_state_db
protected

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

Referenced by __construct().

◆ $pluginslot_by_id

array ilArtifactComponentRepository::$pluginslot_by_id
protected

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


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