ILIAS  trunk Revision v12.0_alpha-1613-gae4c99ebb18
BookableItemTableEditAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29use ILIAS\UI\Factory as UIFactory;
32use ilLanguage;
33
35{
36 public const string ACTION_ID = 'edit';
37 public const string ACTION_LABEL = 'edit';
38
39 public function __construct(
40 private readonly UIFactory $ui_factory,
41 private readonly ilLanguage $lng,
42 private readonly ilCtrlInterface $ctrl,
43 private readonly HttpService $http,
44 private readonly AccessManager $access,
45 private readonly int $ref_id,
46 private readonly bool $active_management,
47 ) {
48 }
49
50 public function getActionId(): string
51 {
52 return self::ACTION_ID;
53 }
54
55 public function getActionLabel(): string
56 {
57 return self::ACTION_LABEL;
58 }
59
60 public function isAvailable(): bool
61 {
62 return $this->active_management && $this->access->canManageObjects($this->ref_id);
63 }
64
65 public function getTableAction(
66 URLBuilder $url_builder,
67 URLBuilderToken $row_id_token,
68 URLBuilderToken $action_token,
69 URLBuilderToken $action_type_token
70 ): Action {
71 return $this->ui_factory->table()->action()->single(
72 $this->lng->txt(self::ACTION_LABEL),
73 $url_builder
74 ->withParameter($action_token, self::ACTION_ID)
75 ->withParameter($action_type_token, 'edit'),
76 $row_id_token
77 );
78 }
79
80 public function onExecute(
81 URLBuilder $url_builder,
82 URLBuilderToken $row_id_token,
83 URLBuilderToken $action_token,
84 URLBuilderToken $action_type_token
85 ): mixed {
86 $row_id = (string) $this->http->resolveRowParameter($row_id_token->getName());
87 $object_id = (int) explode('_', $row_id)[0];
88 if ($object_id <= 0) {
89 return null;
90 }
91
92 $this->ctrl->setParameterByClass(ilBookingObjectGUI::class, 'object_id', (string) $object_id);
93 $this->ctrl->redirectByClass(ilBookingObjectGUI::class, 'edit');
94 return null;
95 }
96
97 public function allowActionForRecord(mixed $record): bool
98 {
99 return true;
100 }
101}
onExecute(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
getTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
__construct(private readonly UIFactory $ui_factory, private readonly ilLanguage $lng, private readonly ilCtrlInterface $ctrl, private readonly HttpService $http, private readonly AccessManager $access, private readonly int $ref_id, private readonly bool $active_management,)
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
@ilCtrl_Calls ilBookingObjectGUI: ilPropertyFormGUI, ilBookingProcessWithScheduleGUI,...
language handling
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
static http()
Fetches the global http state from ILIAS.
global $lng
Definition: privfeed.php:26