ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
Reader.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 
30 class 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 
80  public function activeVocabulariesForSlots(
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 }
__construct(CopyrightBridge $copyright_bridge, ControlledRepo $controlled_repo, StandardRepo $standard_repo)
Definition: Reader.php:36
activeVocabulariesForSlots(SlotIdentifier ... $slots)
Definition: Reader.php:80
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
vocabulariesForSlots(SlotIdentifier ... $slots)
Definition: Reader.php:64