33namespace wcf \system \label \object \type ;
44
55use wcf \data \object \type \ObjectTypeCache ;
6+ use wcf \system \WCF ;
67
78/**
8- * Label object type container.
9+ * This type of container is used to allow the user when editing label groups to specify
10+ * in which sub-areas (e.g., categories or sub-forums) a label group is available.
911 *
1012 * @author Alexander Ebert
1113 * @copyright 2001-2022 WoltLab GmbH
1517final class LabelObjectTypeContainer implements \Countable, \Iterator
1618{
1719 /**
18- * list of object types
1920 * @var LabelObjectType[]
2021 */
21- public array $ objectTypes = [];
22+ private array $ objectTypes = [];
2223
23- /**
24- * object type id
25- */
26- public int $ objectTypeID = 0 ;
27-
28- /**
29- * iterator position
30- */
3124 private int $ position = 0 ;
3225
33- /**
34- * Creates a new LabelObjectTypeContainer object.
35- */
36- public function __construct (int $ objectTypeID )
37- {
38- $ this ->objectTypeID = $ objectTypeID ;
39- }
26+ public function __construct (
27+ public readonly int $ objectTypeID ,
28+ public readonly string $ title = ''
29+ ) {}
4030
4131 /**
4232 * Adds a label object type.
@@ -46,65 +36,47 @@ public function add(LabelObjectType $objectType): void
4636 $ this ->objectTypes [] = $ objectType ;
4737 }
4838
49- /**
50- * Returns the object type id.
51- */
52- public function getObjectTypeID (): int
39+ public function getObjectTypeName (): string
5340 {
54- return $ this ->objectTypeID ;
41+ return ObjectTypeCache:: getInstance ()-> getObjectType ( $ this ->objectTypeID )-> objectType ;
5542 }
5643
57- /**
58- * Returns the object type name.
59- */
60- public function getObjectTypeName (): string
44+ public function getTitle (): string
6145 {
62- return ObjectTypeCache:: getInstance ()->getObjectType ( $ this ->getObjectTypeID ())-> objectType ;
46+ return $ this -> title ?: WCF :: getLanguage ()->get ( ' wcf.acp.label.container. ' . $ this ->getObjectTypeName ());
6347 }
6448
65- /**
66- * @inheritDoc
67- */
49+ #[\Override]
6850 public function current (): LabelObjectType
6951 {
7052 return $ this ->objectTypes [$ this ->position ];
7153 }
7254
73- /**
74- * @inheritDoc
75- */
55+ #[\Override]
7656 public function key (): int
7757 {
7858 return $ this ->position ;
7959 }
8060
81- /**
82- * @inheritDoc
83- */
61+ #[\Override]
8462 public function next (): void
8563 {
8664 $ this ->position ++;
8765 }
8866
89- /**
90- * @inheritDoc
91- */
67+ #[\Override]
9268 public function rewind (): void
9369 {
9470 $ this ->position = 0 ;
9571 }
9672
97- /**
98- * @inheritDoc
99- */
73+ #[\Override]
10074 public function valid (): bool
10175 {
10276 return isset ($ this ->objectTypes [$ this ->position ]);
10377 }
10478
105- /**
106- * @inheritDoc
107- */
79+ #[\Override]
10880 public function count (): int
10981 {
11082 return \count ($ this ->objectTypes );
0 commit comments