ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilComponentFactoryImplementation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected \ilComponentRepositoryWrite $component_repository;
27 protected \ilDBInterface $db;
28
29 protected array $plugins = [];
30
31 public function __construct(
33
34 // These are only required to pass on to the created objects.
36 ) {
37 $this->component_repository = $component_repository;
38
39 // These are only required to pass on to the created objects.
40 $this->db = $db;
41 }
42
43 public function getPlugin(string $id): ilPlugin
44 {
45 if (!isset($this->plugins[$id])) {
46 $plugin_info = $this->component_repository->getPluginById($id);
47 $class_name = $plugin_info->getClassName();
48 $plugin = new $class_name($this->db, $this->component_repository, $id);
49 $this->plugins[$id] = $plugin;
50 }
51
52 return $this->plugins[$id];
53 }
54
55 public function getActivePluginsInSlot(string $slot_id): Generator
56 {
57 $ps = $this->component_repository->getPluginSlotById($slot_id)->getActivePlugins();
58 foreach ($ps as $p) {
59 yield $this->getPlugin($p->getId());
60 }
61 }
62}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(\ilComponentRepositoryWrite $component_repository, \ilDBInterface $db)
getActivePluginsInSlot(string $slot_id)
Get the active plugins for the given slot.
getPlugin(string $id)
Get the plugin for the given id.
Writeable part of repository interface to ilComponentDataDB.
Interface ilDBInterface.