ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilPluginSlotInfo.php
Go to the documentation of this file.
1 <?php
2 
20 declare(strict_types=1);
21 
26 {
28  protected string $id;
29  protected string $name;
33  protected array $plugins;
34 
35  public function __construct(
36  ilComponentInfo $component,
37  string $id,
38  string $name,
39  array &$plugins
40  ) {
41  $this->component = $component;
42  $this->id = $id;
43  $this->name = $name;
44  $this->plugins = &$plugins;
45  }
46 
47  public function getComponent(): ilComponentInfo
48  {
49  return $this->component;
50  }
51 
52  public function getId(): string
53  {
54  return $this->id;
55  }
56 
57  public function getName(): string
58  {
59  return $this->name;
60  }
61 
62  public function getQualifiedName(): string
63  {
64  return $this->component->getQualifiedName() . "/" . $this->getName();
65  }
66 
70  public function getPlugins(): Iterator
71  {
72  foreach ($this->plugins as $id => $plugin) {
73  yield $id => $plugin;
74  }
75  }
76 
77  public function hasPluginId(string $id): bool
78  {
79  return isset($this->plugins[$id]);
80  }
81 
85  public function getPluginById(string $id): \ilPluginInfo
86  {
87  if (!$this->hasPluginId($id)) {
88  throw new \InvalidArgumentException(
89  "No plugin $id in slot {$this->getQualifiedName()}."
90  );
91  }
92  return $this->plugins[$id];
93  }
94 
95  public function hasPluginName(string $name): bool
96  {
97  foreach ($this->getPlugins() as $plugin) {
98  if ($plugin->getName() === $name) {
99  return true;
100  }
101  }
102  return false;
103  }
104 
108  public function getPluginByName(string $name): \ilPluginInfo
109  {
110  foreach ($this->getPlugins() as $plugin) {
111  if ($plugin->getName() === $name) {
112  return $plugin;
113  }
114  }
115  throw new \InvalidArgumentException(
116  "No plugin with name $name in slot {$this->getQualifiedName()}."
117  );
118  }
119 
123  public function getActivePlugins(): Iterator
124  {
125  foreach ($this->getPlugins() as $id => $plugin) {
126  if ($plugin->isActive()) {
127  yield $id => $plugin;
128  }
129  }
130  }
131 
132  public function hasActivePlugins(): bool
133  {
134  foreach ($this->getActivePlugins() as $_) {
135  return true;
136  }
137  return false;
138  }
139 }
__construct(ilComponentInfo $component, string $id, string $name, array &$plugins)
Simple value class for basic information about a pluginslot.
ilComponentInfo $component
Simple value class for information about a plugin.
Simple value class for basic information about a component.