ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilPluginSlotInfo.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
27  protected string $id;
28  protected string $name;
32  protected array $plugins;
33 
34  public function __construct(
35  ilComponentInfo $component,
36  string $id,
37  string $name,
38  array &$plugins
39  ) {
40  $this->component = $component;
41  $this->id = $id;
42  $this->name = $name;
43  $this->plugins = &$plugins;
44  }
45 
46  public function getComponent(): ilComponentInfo
47  {
48  return $this->component;
49  }
50 
51  public function getId(): string
52  {
53  return $this->id;
54  }
55 
56  public function getName(): string
57  {
58  return $this->name;
59  }
60 
61  public function getQualifiedName(): string
62  {
63  return $this->component->getQualifiedName() . "/" . $this->getName();
64  }
65 
69  public function getPlugins(): Iterator
70  {
71  foreach ($this->plugins as $id => $plugin) {
72  yield $id => $plugin;
73  }
74  }
75 
76  public function hasPluginId(string $id): bool
77  {
78  return isset($this->plugins[$id]);
79  }
80 
84  public function getPluginById(string $id): \ilPluginInfo
85  {
86  if (!$this->hasPluginId($id)) {
87  throw new \InvalidArgumentException(
88  "No plugin $id in slot {$this->getQualifiedName()}."
89  );
90  }
91  return $this->plugins[$id];
92  }
93 
94  public function hasPluginName(string $name): bool
95  {
96  foreach ($this->getPlugins() as $plugin) {
97  if ($plugin->getName() === $name) {
98  return true;
99  }
100  }
101  return false;
102  }
103 
107  public function getPluginByName(string $name): \ilPluginInfo
108  {
109  foreach ($this->getPlugins() as $plugin) {
110  if ($plugin->getName() === $name) {
111  return $plugin;
112  }
113  }
114  throw new \InvalidArgumentException(
115  "No plugin with name $name in slot {$this->getQualifiedName()}."
116  );
117  }
118 
122  public function getActivePlugins(): Iterator
123  {
124  foreach ($this->getPlugins() as $id => $plugin) {
125  if ($plugin->isActive()) {
126  yield $id => $plugin;
127  }
128  }
129  }
130 
131  public function hasActivePlugins(): bool
132  {
133  foreach ($this->getActivePlugins() as $_) {
134  return true;
135  }
136  return false;
137  }
138 }
__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.