ILIAS  release_8 Revision v8.24
class.ilPluginSlotInfo.php
Go to the documentation of this file.
1<?php
19declare(strict_types=1);
20
25{
27 protected string $id;
28 protected string $name;
32 protected array $plugins;
33
34 public function __construct(
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
66 public function getPath(): string
67 {
69 }
70
74 public function getPlugins(): Iterator
75 {
76 foreach ($this->plugins as $id => $plugin) {
77 yield $id => $plugin;
78 }
79 }
80
81 public function hasPluginId(string $id): bool
82 {
83 return isset($this->plugins[$id]);
84 }
85
89 public function getPluginById(string $id): \ilPluginInfo
90 {
91 if (!$this->hasPluginId($id)) {
92 throw new \InvalidArgumentException(
93 "No plugin $id in slot {$this->getQualifiedName()}."
94 );
95 }
96 return $this->plugins[$id];
97 }
98
99 public function hasPluginName(string $name): bool
100 {
101 foreach ($this->getPlugins() as $plugin) {
102 if ($plugin->getName() === $name) {
103 return true;
104 }
105 }
106 return false;
107 }
108
112 public function getPluginByName(string $name): \ilPluginInfo
113 {
114 foreach ($this->getPlugins() as $plugin) {
115 if ($plugin->getName() === $name) {
116 return $plugin;
117 }
118 }
119 throw new \InvalidArgumentException(
120 "No plugin with name $name in slot {$this->getQualifiedName()}."
121 );
122 }
123
127 public function getActivePlugins(): Iterator
128 {
129 foreach ($this->getPlugins() as $id => $plugin) {
130 if ($plugin->isActive()) {
131 yield $id => $plugin;
132 }
133 }
134 }
135
136 public function hasActivePlugins(): bool
137 {
138 foreach ($this->getActivePlugins() as $_) {
139 return true;
140 }
141 return false;
142 }
143}
Simple value class for basic information about a component.
Simple value class for information about a plugin.
Simple value class for basic information about a pluginslot.
__construct(ilComponentInfo $component, string $id, string $name, array &$plugins)
ilComponentInfo $component