ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Bridge.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\MetaData\Copyright\RepositoryInterface as CopyrightRepository;
31
32class Bridge implements BridgeInterface
33{
36 protected CopyrightRepository $copyright_repository;
37 protected IdentifierHandler $identifier_handler;
38
39 public function __construct(
42 CopyrightRepository $copyright_repository,
43 IdentifierHandler $identifier_handler
44 ) {
45 $this->factory = $factory;
46 $this->settings = $settings;
47 $this->copyright_repository = $copyright_repository;
48 $this->identifier_handler = $identifier_handler;
49 }
50
51 public function vocabulary(SlotIdentifier $slot): ?VocabularyInterface
52 {
53 if (
54 !$this->settings->isCopyrightSelectionActive() ||
55 $slot !== SlotIdentifier::RIGHTS_DESCRIPTION
56 ) {
57 return null;
58 }
59
60 $values = [];
61 foreach ($this->copyright_repository->getAllEntries() as $copyright) {
62 $values[] = $this->identifier_handler->buildIdentifierFromEntryID($copyright->id());
63 }
64 if (empty($values)) {
65 return null;
66 }
67 return $this->factory->copyright(...$values)->get();
68 }
69
73 public function labelsForValues(
74 SlotIdentifier $slot,
75 string ...$values
76 ): \Generator {
77 if (
78 !$this->settings->isCopyrightSelectionActive() ||
79 $slot !== SlotIdentifier::RIGHTS_DESCRIPTION
80 ) {
81 return;
82 }
83
84 foreach ($this->copyright_repository->getAllEntries() as $copyright) {
85 $identifier = $this->identifier_handler->buildIdentifierFromEntryID($copyright->id());
86 if (!in_array($identifier, $values)) {
87 continue;
88 }
89 yield new LabelledValue(
90 $identifier,
91 $copyright->title()
92 );
93 }
94 }
95}
factory()
__construct(FactoryInterface $factory, SettingsInterface $settings, CopyrightRepository $copyright_repository, IdentifierHandler $identifier_handler)
Definition: Bridge.php:39
CopyrightRepository $copyright_repository
Definition: Bridge.php:36
labelsForValues(SlotIdentifier $slot, string ... $values)
Definition: Bridge.php:73
if(!file_exists('../ilias.ini.php'))