ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
LinkBuilder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use ILIAS\Data\URI;
25 
27 {
28  protected \ilCtrlInterface $ctrl;
30 
34  protected array $parameters = [];
35  protected Command $command;
36 
37  public function __construct(
38  \ilCtrlInterface $ctrl,
39  DataFactory $data_factory,
40  Command $command
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 }
parameters()
description: > This shows how different states are being used in the same Prompt according to parame...
Definition: parameters.php:39
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withParameter(Parameter $parameter, string $value)
Definition: LinkBuilder.php:47
__construct(\ilCtrlInterface $ctrl, DataFactory $data_factory, Command $command)
Definition: LinkBuilder.php:37