ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LinkBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\Data\Factory as DataFactory;
25
27{
28 protected \ilCtrlInterface $ctrl;
29 protected DataFactory $data_factory;
30
34 protected array $parameters = [];
35 protected Command $command;
36
37 public function __construct(
39 DataFactory $data_factory,
41 ) {
42 $this->ctrl = $ctrl;
43 $this->data_factory = $data_factory;
44 $this->command = $command;
45 }
46
47 public function withParameter(
48 Parameter $parameter,
49 string $value
50 ): LinkBuilder {
51 $clone = clone $this;
52 $clone->parameters[$parameter->value] = $value;
53 return $clone;
54 }
55
56 public function get(): URI
57 {
58 $class = strtolower(\ilMDEditorGUI::class);
59 foreach ($this->parameters as $key => $value) {
60 $this->ctrl->setParameterByClass(
61 $class,
62 $key,
63 urlencode($value)
64 );
65 }
66 $link = ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
67 $class,
68 $this->command->value
69 );
70 $this->ctrl->clearParametersByClass($class);
71 return $this->data_factory->uri($link);
72 }
73}
Builds data types.
Definition: Factory.php:36
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
__construct(\ilCtrlInterface $ctrl, DataFactory $data_factory, Command $command)
Definition: LinkBuilder.php:37
withParameter(Parameter $parameter, string $value)
Definition: LinkBuilder.php:47
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...