ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
StandardURIBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
30{
31 public function __construct(
32 private string $ILIAS_HTTP_PATH,
33 private bool $short_url_possible = false
34 ) {
35 }
36
37 public const SHORT = '/go/';
38 public const LONG = '/goto.php/';
39
40 public function build(
41 string $namespace,
42 ?ReferenceId $reference_id = null,
43 array $additional_parameters = []
44 ): URI {
45 $uri = $this->getBaseURI()
46 . ($this->short_url_possible ? self::SHORT : self::LONG)
47 . $this->buildTarget($namespace, $reference_id, $additional_parameters);
48
49 return new URI($uri);
50 }
51
52 public function buildTarget(
53 string $namespace,
54 ?ReferenceId $reference_id = null,
55 array $additional_parameters = []
56 ): string {
58 . ($reference_id !== null ? '/' . $reference_id->toInt() : '')
59 . '/'
60 . implode('/', $additional_parameters);
61 }
62
63 public function getBaseURI(): URI
64 {
65 $base_path = $this->ILIAS_HTTP_PATH;
66
67 $offset = match (true) {
68 str_contains($base_path, self::SHORT) => strpos($base_path, self::SHORT),
69 str_contains($base_path, self::LONG) => strpos($base_path, rtrim(self::LONG, '/')),
70 str_contains($base_path, rtrim(self::LONG, '/')) => strpos($base_path, rtrim(self::LONG, '/')),
71 str_contains($base_path, 'Customizing') => strpos($base_path, 'Customizing'),
72 str_contains($base_path, 'src') => strpos($base_path, 'src'),
73 str_contains($base_path, 'webservices') => strpos($base_path, 'webservices'),
74 default => false,
75 };
76
77 if ($offset === false) {
78 return new URI(trim($base_path, '/'));
79 }
80
81 $uri_string = substr(
82 $base_path,
83 0,
84 $offset
85 );
86 return new URI(
87 trim($uri_string, '/')
88 );
89 }
90
91}
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
__construct(private string $ILIAS_HTTP_PATH, private bool $short_url_possible=false)
buildTarget(string $namespace, ?ReferenceId $reference_id=null, array $additional_parameters=[])
build(string $namespace, ?ReferenceId $reference_id=null, array $additional_parameters=[])
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($err=$client->getError()) $namespace