ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
CopyrightHandler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\MetaData\Copyright\RepositoryInterface as CopyrightRepository;
28
30{
34 protected array $entries;
35
36 public function __construct(
37 protected CopyrightRepository $repository,
38 protected Settings $settings,
39 protected OERHarvesterSettings $harvester_settings,
40 protected CopyrightIDHandler $copyright_id_handler
41 ) {
42 }
43
44 public function isCPSelectionActive(): bool
45 {
46 return $this->settings->isCopyrightSelectionActive() && $this->hasCPEntries();
47 }
48
49 protected function hasCPEntries(): bool
50 {
51 $this->initCPEntries();
52 return !empty($this->entries);
53 }
54
58 public function getCPEntries(): \Generator
59 {
60 $this->initCPEntries();
61 yield from $this->entries;
62 }
63
64 protected function initCPEntries(): void
65 {
66 if (!isset($this->entries)) {
67 $this->entries = iterator_to_array($this->repository->getAllEntries());
68 }
69 }
70
71 public function extractCPEntryID(string $description): int
72 {
73 return $this->copyright_id_handler->parseEntryIDFromIdentifier($description);
74 }
75
76 public function createIdentifierForID(int $entry_id): string
77 {
78 return $this->copyright_id_handler->buildIdentifierFromEntryID($entry_id);
79 }
80
81 public function isObjectTypePublished(string $type): bool
82 {
83 return $this->harvester_settings->isObjectTypeSelectedForPublishing($type);
84 }
85
86 public function isCopyrightEntryPublished(EntryInterface $entry): bool
87 {
88 return $this->harvester_settings->isCopyrightEntryIDSelectedForPublishing($entry->id());
89 }
90}
__construct(protected CopyrightRepository $repository, protected Settings $settings, protected OERHarvesterSettings $harvester_settings, protected CopyrightIDHandler $copyright_id_handler)