ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Handler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23class Handler implements HandlerInterface
24{
25 public function buildIdentifierFromEntryID(int $entry_id): string
26 {
27 return 'il_copyright_entry__' . $this->getInstID() . '__' . $entry_id;
28 }
29
30 public function isIdentifierValid(string $identifier): bool
31 {
32 if (!preg_match('/il_copyright_entry__([0-9]+)__([0-9]+)/', $identifier, $matches)) {
33 return false;
34 }
35 if (($matches[1] ?? '') !== $this->getInstID()) {
36 return false;
37 }
38 return true;
39 }
40
41 public function parseEntryIDFromIdentifier(string $identifier): int
42 {
43 if (!preg_match('/il_copyright_entry__([0-9]+)__([0-9]+)/', $identifier, $matches)) {
44 return 0;
45 }
46 if (($matches[1] ?? '') !== $this->getInstID()) {
47 return 0;
48 }
49 return (int) ($matches[2] ?? 0);
50 }
51
52 protected function getInstID(): string
53 {
54 return (string) IL_INST_ID;
55 }
56}
parseEntryIDFromIdentifier(string $identifier)
Definition: Handler.php:41
const IL_INST_ID
Definition: constants.php:40