20 declare(strict_types=1);
55 $this->components = [];
56 $this->component_id_by_type_and_name = [
60 $this->pluginslot_by_id = [];
61 $plugins_per_slot = [];
62 foreach ($component_data as $comp_id => [
$type, $comp_name, $slot_data]) {
70 foreach ($slot_data as [$slot_id, $slot_name]) {
71 $plugins_per_slot[$slot_id] = [];
76 $plugins_per_slot[$slot_id]
78 $this->pluginslot_by_id[$slot_id] = $slots[$slot_id];
80 $this->components[$comp_id] = $component;
81 $this->component_id_by_type_and_name[
$type][$comp_name] = $comp_id;
84 $this->plugin_by_id = [];
85 foreach ($plugin_data as $plugin_id =>
$data) {
101 throw new \InvalidArgumentException(
102 "Can't find component $type/$comp_name for plugin $plugin_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" 111 $slot = $component->getPluginSlotByName($slot_name);
113 $this->ilias_version,
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),
125 $learning_progress ??
false,
126 $supports_export ??
false,
127 $supports_cli_setup ?? true
129 $plugins_per_slot[$slot->getId()][$plugin_id] = $this->plugin_by_id[$plugin_id];
135 return require self::COMPONENT_DATA_PATH;
140 return require self::PLUGIN_DATA_PATH;
149 throw new \InvalidArgumentException(
150 "Unknown component type $type." 154 return isset($this->component_id_by_type_and_name[$type][$name]);
162 return isset($this->components[$id]);
170 foreach ($this->components as
$id => $comp) {
181 throw new \InvalidArgumentException(
182 "Unknown component $id" 185 return $this->components[
$id];
194 throw new \InvalidArgumentException(
195 "Unknown component $type/$name" 198 return $this->components[$this->component_id_by_type_and_name[
$type][
$name]];
207 return isset($this->pluginslot_by_id[$id]);
215 foreach ($this->pluginslot_by_id as
$id => $slot) {
226 throw new \InvalidArgumentException(
227 "Unknown pluginslot $id" 230 return $this->pluginslot_by_id[
$id];
238 return isset($this->plugin_by_id[$id]);
250 foreach ($this->plugin_by_id as
$id =>
$plugin) {
263 throw new \InvalidArgumentException(
264 "Unknown plugin $id." 267 return $this->plugin_by_id[
$id];
278 if ($plugin->getName() ===
$name) {
282 throw new \InvalidArgumentException(
283 "No plugin with name $name." 290 if (
$plugin->getCurrentVersion() !== null &&
$plugin->getCurrentVersion()->isGreaterThan($version)) {
291 throw new \RuntimeException(
292 "Cannot downgrade plugins version from {$plugin->getCurrentVersion()} to $version" 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" 300 $this->plugin_state_db->setCurrentPluginVersion($plugin_id, $version, $db_version);
307 throw new \InvalidArgumentException(
308 "Unknown plugin $plugin_id." 311 $this->plugin_state_db->setActivation($plugin_id, $activated);
318 throw new \InvalidArgumentException(
319 "Unknown plugin $plugin_id." 322 $this->plugin_state_db->remove($plugin_id);
hasActivatedPlugin(string $id)
Check if a plugin exists and is activated.
setCurrentPluginVersion(string $plugin_id, Data\Version $version, int $db_version)
hasPluginSlotId(string $id)
Writeable part of repository interface to ilComponentDataDB.
const COMPONENT_DATA_PATH
ilPluginStateDB $plugin_state_db
hasComponentId(string $id)
getComponentByTypeAndName(string $type, string $name)
Simple value class for basic information about a pluginslot.
Data Factory $data_factory
hasPluginId(string $id)
Check if a plugin exists.
getPluginByName(string $name)
Get a plugin by name.
__construct(Data\Factory $data_factory, ilPluginStateDB $plugin_state_db, Data\Version $ilias_version)
array $component_id_by_type_and_name
getPluginSlotById(string $id)
removeStateInformationOf(string $plugin_id)
setActivation(string $plugin_id, bool $activated)
Repository interface for plugin state data.
Simple value class for information about a plugin.
getPluginById(string $id)
Get a plugin by id.
Repository for component data implemented over artifacts.
Data Version $ilias_version
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
A version number that consists of three numbers (major, minor, patch).
hasComponent(string $type, string $name)
getComponentById(string $id)
getPlugins()
Get all plugins.
Simple value class for basic information about a component.