ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LSUrlBuilder.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
10 class LSUrlBuilder implements URLBuilder
11 {
12  const PARAM_LSO_COMMAND = 'lsocmd';
13  const PARAM_LSO_PARAMETER = 'lsov';
14 
15  public function __construct(ILIAS\Data\URI $base_url)
16  {
17  $this->base_url = $base_url;
18  }
19 
20  public function getURL(string $command, int $param = null) : ILIAS\Data\URI
21  {
22  $query = $this->base_url->query();
23  if (!$query) {
24  $params = [];
25  } else {
26  parse_str($this->base_url->query(), $params);
27  }
28 
29  $params[self::PARAM_LSO_COMMAND] = $command;
30  if (is_null($param)) {
31  unset($params[self::PARAM_LSO_PARAMETER]);
32  } else {
33  $params[self::PARAM_LSO_PARAMETER] = $param;
34  }
35  $url = $this->base_url->withQuery(http_build_query($params));
36  return $url;
37  }
38 
39  public function getHref(string $command, int $param = null) : string
40  {
41  $url = $this->getURL($command, $param);
42  return $url->baseURI() . '?' . $url->query();
43  }
44 }
Class BaseForm.
const PARAM_LSO_COMMAND
__construct(ILIAS\Data\URI $base_url)
Class LSUrlBuilder.
const PARAM_LSO_PARAMETER
$query
getHref(string $command, int $param=null)
The URLBuilder allows views to get links that are used somewhere inline in the content.
Definition: URLBuilder.php:12
$url
getURL(string $command, int $param=null)
Get an URL for the provided command and params.