ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Reader.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29
30class Reader implements ReaderInterface
31{
32 protected CopyrightBridge $copyright_bridge;
33 protected ControlledRepo $controlled_repo;
34 protected StandardRepo $standard_repo;
35
36 public function __construct(
37 CopyrightBridge $copyright_bridge,
38 ControlledRepo $controlled_repo,
39 StandardRepo $standard_repo
40 ) {
41 $this->copyright_bridge = $copyright_bridge;
42 $this->controlled_repo = $controlled_repo;
43 $this->standard_repo = $standard_repo;
44 }
45
46 public function vocabulary(string $vocab_id): VocabularyInterface
47 {
48 $slot = SlotIdentifier::tryFrom($vocab_id);
49 if ($slot === null) {
50 return $this->controlled_repo->getVocabulary($vocab_id);
51 }
52
53 $from_copyright = $this->copyright_bridge->vocabulary($slot);
54 if ($from_copyright !== null) {
55 return $from_copyright;
56 }
57
58 return $this->standard_repo->getVocabulary($slot);
59 }
60
64 public function vocabulariesForSlots(
65 SlotIdentifier ...$slots
66 ): \Generator {
67 foreach ($slots as $slot) {
68 $from_copyright = $this->copyright_bridge->vocabulary($slot);
69 if (!is_null($from_copyright)) {
70 yield $from_copyright;
71 }
72 }
73 yield from $this->controlled_repo->getVocabulariesForSlots(...$slots);
74 yield from $this->standard_repo->getVocabularies(...$slots);
75 }
76
81 SlotIdentifier ...$slots
82 ): \Generator {
83 foreach ($slots as $slot) {
84 $from_copyright = $this->copyright_bridge->vocabulary($slot);
85 if (!is_null($from_copyright) && $from_copyright->isActive()) {
86 yield $from_copyright;
87 }
88 }
89 yield from $this->controlled_repo->getActiveVocabulariesForSlots(...$slots);
90 yield from $this->standard_repo->getActiveVocabularies(...$slots);
91 }
92}
vocabulariesForSlots(SlotIdentifier ... $slots)
Definition: Reader.php:64
__construct(CopyrightBridge $copyright_bridge, ControlledRepo $controlled_repo, StandardRepo $standard_repo)
Definition: Reader.php:36
activeVocabulariesForSlots(SlotIdentifier ... $slots)
Definition: Reader.php:80