ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
LinkFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
29{
30 public function __construct(
31 protected ilCtrlInterface $ctrl
32 ) {
33 }
34
35 public function getViewLink(int $ref_id, int $obj_id, string $type): string
36 {
37 return $this->getLinkForCommand(Command::VIEW, $ref_id, $obj_id, $type);
38 }
39
40 public function getLinkForAction(Action $action, int $ref_id, int $obj_id, string $type): string
41 {
42 $cmd = match ($action) {
43 Action::BLOCK => Command::BLOCK,
44 Action::UNBLOCK => Command::UNBLOCK,
45 Action::PUBLISH => Command::PUBLISH,
46 Action::WITHDRAW => Command::WITHDRAW,
47 Action::SUBMIT => Command::SUBMIT,
48 Action::ACCEPT => Command::ACCEPT,
50 };
51 return $this->getLinkForCommand($cmd, $ref_id, $obj_id, $type);
52 }
53
54 public function getLinkForConfirmationOfAction(Action $action, int $ref_id, int $obj_id, string $type): string
55 {
56 $cmd = match ($action) {
57 Action::WITHDRAW => Command::CONFIRM_WITHDRAW,
58 Action::ACCEPT => Command::CONFIRM_ACCEPT,
60 default => null
61 };
62 if ($cmd === null) {
63 return '';
64 }
65 return $this->getLinkForCommand($cmd, $ref_id, $obj_id, $type);
66 }
67
68 protected function getLinkForCommand(Command $cmd, int $ref_id, int $obj_id, string $type): string
69 {
70 $this->ctrl->setParameterByClass(ControlCenterGUI::class, RequestParserInterface::REF_ID_PARAM, $ref_id);
71 $this->ctrl->setParameterByClass(ControlCenterGUI::class, RequestParserInterface::OBJ_ID_PARAM, $obj_id);
72 $this->ctrl->setParameterByClass(ControlCenterGUI::class, RequestParserInterface::TYPE_PARAM, $type);
73 $link = $this->ctrl->getLinkTargetByClass(ControlCenterGUI::class, $cmd->value, null, true);
74 $this->ctrl->clearParameterByClass(ControlCenterGUI::class, RequestParserInterface::REF_ID_PARAM);
75 $this->ctrl->clearParameterByClass(ControlCenterGUI::class, RequestParserInterface::OBJ_ID_PARAM);
76 $this->ctrl->clearParameterByClass(ControlCenterGUI::class, RequestParserInterface::TYPE_PARAM);
77
78 return $link;
79 }
80}
getLinkForConfirmationOfAction(Action $action, int $ref_id, int $obj_id, string $type)
Definition: LinkFactory.php:54
getLinkForAction(Action $action, int $ref_id, int $obj_id, string $type)
Definition: LinkFactory.php:40
getLinkForCommand(Command $cmd, int $ref_id, int $obj_id, string $type)
Definition: LinkFactory.php:68
getViewLink(int $ref_id, int $obj_id, string $type)
Definition: LinkFactory.php:35
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66