ILIAS  release_8 Revision v8.24
MaxNestingPathGenerator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
31{
32 private const MAX_NESTING_256 = 256;
33 private const MAX_NESTING_4096 = 4096;
34 private const MAX_NESTING_65536 = 65536;
35
37 protected int $splitter = 3;
38 protected int $limited_layers = 3;
39
43 public function __construct()
44 {
45 switch ($this->max_nesting) {
47 $this->splitter = 3;
48 break;
50 $this->splitter = 4;
51 break;
52 default:
53 $this->splitter = 2;
54 break;
55 }
56 }
57
58 public function getPathFor(ResourceIdentification $i): string
59 {
60 $splitted = str_split(str_replace("-", "", $i->serialize()), $this->splitter);
61
62 $first_part = array_slice($splitted, 0, $this->limited_layers + 1);
63 $second_part = array_slice($splitted, $this->limited_layers + 1);
64
65 return implode("/", $first_part) . implode("", $second_part);
66 }
67
69 {
70 $str = str_replace("/", "", $path);
71
72 $p1 = substr($str, 0, 8);
73 $p2 = substr($str, 8, 4);
74 $p3 = substr($str, 12, 4);
75 $p4 = substr($str, 16, 4);
76 $p5 = substr($str, 20, 12);
77
78 return new ResourceIdentification("$p1-$p2-$p3-$p4-$p5");
79 }
80}
$path
Definition: ltiservices.php:32
$i
Definition: metadata.php:41