ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
CopyrightHandler.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 
31 {
33  protected Settings $settings;
35  protected HarvestStatusRepository $harvest_status_repo;
37 
41  protected array $entries;
42 
43  public function __construct(
44  CopyrightRepository $repository,
45  Settings $settings,
46  OERHarvesterSettings $harvester_settings,
47  HarvestStatusRepository $harvest_status_repo,
48  CopyrightIDHandler $copyright_id_handler
49  ) {
50  $this->repository = $repository;
51  $this->settings = $settings;
52  $this->harvester_settings = $harvester_settings;
53  $this->harvest_status_repo = $harvest_status_repo;
54  $this->copyright_id_handler = $copyright_id_handler;
55  }
56 
57  public function isCPSelectionActive(): bool
58  {
59  return $this->settings->isCopyrightSelectionActive() && $this->hasCPEntries();
60  }
61 
62  public function isObjectTypeHarvested(string $type): bool
63  {
64  return $this->harvester_settings->isObjectTypeSelectedForHarvesting($type);
65  }
66 
67  public function isCopyrightTemplateActive(EntryInterface $entry): bool
68  {
69  return $this->harvester_settings->isCopyrightEntryIDSelectedForHarvesting($entry->id());
70  }
71 
72  protected function hasCPEntries(): bool
73  {
74  $this->initCPEntries();
75  return !empty($this->entries);
76  }
77 
81  public function getCPEntries(): \Generator
82  {
83  $this->initCPEntries();
84  yield from $this->entries;
85  }
86 
87  protected function initCPEntries(): void
88  {
89  if (!isset($this->entries)) {
90  $this->entries = iterator_to_array($this->repository->getAllEntries());
91  }
92  }
93 
94  public function extractCPEntryID(string $description): int
95  {
96  return $this->copyright_id_handler->parseEntryIDFromIdentifier($description);
97  }
98 
99  public function createIdentifierForID(int $entry_id): string
100  {
101  return $this->copyright_id_handler->buildIdentifierFromEntryID($entry_id);
102  }
103 
104  public function isOerHarvesterBlocked(int $obj_id): bool
105  {
106  return $this->harvest_status_repo->isHarvestingBlocked($obj_id);
107  }
108 
109  public function setOerHarvesterBlocked(
110  int $obj_id,
111  bool $is_blocked
112  ): void {
113  $this->harvest_status_repo->setHarvestingBlocked($obj_id, $is_blocked);
114  }
115 }
repository()
description: > Example for rendering a repository card
Definition: repository.php:33
__construct(CopyrightRepository $repository, Settings $settings, OERHarvesterSettings $harvester_settings, HarvestStatusRepository $harvest_status_repo, CopyrightIDHandler $copyright_id_handler)
setOerHarvesterBlocked(int $obj_id, bool $is_blocked)