ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Handler.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 class 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 }
const IL_INST_ID
Definition: constants.php:40
parseEntryIDFromIdentifier(string $identifier)
Definition: Handler.php:41