ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilComponentInfo.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 // TODO: to be replaced with an enum for PHP 8.1...
27 public const TYPE_COMPONENT = "components/ILIAS";
28 public const TYPE_MODULES = "Modules";
29 public const TYPE_SERVICES = "Services";
30 public const TYPES = [self::TYPE_COMPONENT];
31
32 protected string $id;
33 protected string $type;
34 protected string $name;
38 protected array $pluginslots;
39
40 public function __construct(
41 string $id,
42 string $type,
43 string $name,
44 array &$pluginslots
45 ) {
46 if (!in_array($type, self::TYPES)) {
47 throw new \InvalidArgumentException(
48 "Invalid component type: $type"
49 );
50 }
51
52 $this->id = $id;
53 $this->type = $type;
54 $this->name = $name;
55 $this->pluginslots = &$pluginslots;
56 }
57
58 public function getId(): string
59 {
60 return $this->id;
61 }
62
63 public function getType(): string
64 {
65 return $this->type;
66 }
67
68 public function getName(): string
69 {
70 return $this->name;
71 }
72
73 public function getQualifiedName(): string
74 {
75 return $this->type . "/" . $this->name;
76 }
77
81 public function getPluginSlots(): Iterator
82 {
83 foreach ($this->pluginslots as $id => $slot) {
84 yield $slot->getId() => $slot;
85 }
86 }
87
88 public function hasPluginSlotId(string $id): bool
89 {
90 foreach ($this->pluginslots as $slot) {
91 if ($slot->getId() === $id) {
92 return true;
93 }
94 }
95 return false;
96 }
97
101 public function getPluginSlotById(string $id): \ilPluginSlotInfo
102 {
103 foreach ($this->pluginslots as $slot) {
104 if ($slot->getId() === $id) {
105 return $slot;
106 }
107 }
108 throw new \InvalidArgumentException(
109 "No plugin slot $id at component {$this->getQualifiedName()}"
110 );
111 }
112
113 public function hasPluginSlotName(string $name): bool
114 {
115 foreach ($this->pluginslots as $slot) {
116 if ($slot->getName() === $name) {
117 return true;
118 }
119 }
120 return false;
121 }
122
127 {
128 foreach ($this->pluginslots as $slot) {
129 if ($slot->getName() === $name) {
130 return $slot;
131 }
132 }
133 throw new \InvalidArgumentException(
134 "No plugin slot $name at component {$this->getQualifiedName()}"
135 );
136 }
137}
Simple value class for basic information about a component.
getPluginSlotByName(string $name)
__construct(string $id, string $type, string $name, array &$pluginslots)
hasPluginSlotName(string $name)
Simple value class for basic information about a pluginslot.