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