ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Test\Settings\Templates\PersonalSettingsTableActions Class Reference
+ Collaboration diagram for ILIAS\Test\Settings\Templates\PersonalSettingsTableActions:

Public Member Functions

 __construct (private readonly RequestDataCollector $test_request, private readonly ResponseHandler $test_response, private readonly UIRenderer $ui_renderer, private readonly UIFactory $ui_factory, private readonly Language $lng, private readonly \ilObjUser $user, private readonly PersonalSettingsRepository $repository, private readonly array $actions)
 
 getActions (URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
 
 getAction (string $action_id)
 
 perform (URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
 

Data Fields

const string ROW_ID_PARAMETER = 't_id'
 
const string ACTION_PARAMETER = 'action'
 
const string ACTION_TYPE_PARAMETER = 'action_type'
 
const string SUBMIT_ACTION = 'submitTableAction'
 

Private Member Functions

 submit (TableAction $action, URLBuilder $url_builder, array $selection,)
 
 showModal (TableAction $action, URLBuilder $url_builder, array $selection,)
 
 checkAccess (array $selection)
 
 fail (string $message_key)
 

Detailed Description

Definition at line 32 of file PersonalSettingsTableActions.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::__construct ( private readonly RequestDataCollector  $test_request,
private readonly ResponseHandler  $test_response,
private readonly UIRenderer  $ui_renderer,
private readonly UIFactory  $ui_factory,
private readonly Language  $lng,
private readonly \ilObjUser  $user,
private readonly PersonalSettingsRepository  $repository,
private readonly array  $actions 
)
Parameters
array<string,TableAction>$actions

Definition at line 42 of file PersonalSettingsTableActions.php.

51 {
52 }

Member Function Documentation

◆ checkAccess()

ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::checkAccess ( array  $selection)
private
Parameters
PersonalSettingsTemplate[]$selection

Definition at line 148 of file PersonalSettingsTableActions.php.

148 : bool
149 {
150 foreach ($selection as $template) {
151 if ($this->user->getId() !== $template->getUserId()) {
152 return false;
153 }
154 }
155 return true;
156 }

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ fail()

ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::fail ( string  $message_key)
private

Definition at line 158 of file PersonalSettingsTableActions.php.

158 : null
159 {
160 $this->test_response->sendAsync(
161 $this->ui_renderer->renderAsync(
162 $this->ui_factory->messageBox()->failure($this->lng->txt($message_key))
163 )
164 );
165 return null;
166 }

◆ getAction()

ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::getAction ( string  $action_id)

Definition at line 68 of file PersonalSettingsTableActions.php.

69 {
70 return $this->actions[$action_id] ?? null;
71 }

◆ getActions()

ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::getActions ( URLBuilder  $url_builder,
URLBuilderToken  $row_id_token,
URLBuilderToken  $action_token,
URLBuilderToken  $action_type_token 
)

Definition at line 54 of file PersonalSettingsTableActions.php.

59 : array {
60 return array_map(fn(TableAction $action) => $action->buildTableAction(
61 $url_builder,
62 $row_id_token,
63 $action_token,
64 $action_type_token
65 ), $this->actions);
66 }
buildTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)

◆ perform()

ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::perform ( URLBuilder  $url_builder,
URLBuilderToken  $row_id_token,
URLBuilderToken  $action_token,
URLBuilderToken  $action_type_token 
)

Definition at line 73 of file PersonalSettingsTableActions.php.

78 : ?Modal {
79 $selection_ids = $this->test_request->getMultiSelectionIds($row_id_token->getName());
80
81 $selection = $selection_ids === 'ALL_OBJECTS'
82 ? $this->repository->getForUser()
83 : $this->repository->getByIds($selection_ids);
84
85 if ($selection === []) {
86 return $this->fail('personal_settings_invalid_selection');
87 }
88
89 if (!$this->checkAccess($selection)) {
90 return $this->fail('no_permission');
91 }
92
93 $action = $this->getAction($this->test_request->strVal($action_token->getName()));
94 try {
95 $url_builder = $url_builder
96 ->withParameter($row_id_token, $selection_ids)
97 ->withParameter($action_token, $action->getActionId())
98 ->withParameter($action_type_token, self::SUBMIT_ACTION);
99
100 return match ($this->test_request->strVal($action_type_token->getName())) {
101 self::SUBMIT_ACTION => $this->submit(
102 $action,
103 $url_builder,
104 $selection,
105 ),
106 default => $this->showModal(
107 $action,
108 $url_builder,
109 $selection,
110 )
111 };
112 } catch (\InvalidArgumentException $e) {
113 return $this->fail($e->getMessage());
114 }
115 }
submit(TableAction $action, URLBuilder $url_builder, array $selection,)
showModal(TableAction $action, URLBuilder $url_builder, array $selection,)
getName()
Get the full name of the token including its namespace.
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166

◆ showModal()

ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::showModal ( TableAction  $action,
URLBuilder  $url_builder,
array  $selection 
)
private

Definition at line 129 of file PersonalSettingsTableActions.php.

133 : null {
134 $this->test_response->sendAsync(
135 $this->ui_renderer->renderAsync(
136 $action->buildModal(
137 $url_builder,
138 $selection,
139 )
140 )
141 );
142 return null;
143 }
buildModal(URLBuilder $url_builder, array $selected_templates)

◆ submit()

ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::submit ( TableAction  $action,
URLBuilder  $url_builder,
array  $selection 
)
private

Definition at line 117 of file PersonalSettingsTableActions.php.

121 : ?Modal {
122 return $action->onSubmit(
123 $url_builder,
124 $this->test_request->getRequest(),
125 $selection,
126 );
127 }
onSubmit(URLBuilder $url_builder, ServerRequestInterface $request, array $selected_templates,)

Field Documentation

◆ ACTION_PARAMETER

const string ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::ACTION_PARAMETER = 'action'

◆ ACTION_TYPE_PARAMETER

const string ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::ACTION_TYPE_PARAMETER = 'action_type'

◆ ROW_ID_PARAMETER

const string ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::ROW_ID_PARAMETER = 't_id'

◆ SUBMIT_ACTION

const string ILIAS\Test\Settings\Templates\PersonalSettingsTableActions::SUBMIT_ACTION = 'submitTableAction'

Definition at line 37 of file PersonalSettingsTableActions.php.


The documentation for this class was generated from the following file: