Skip to content

Commit

Permalink
feat: Added customizable getDefaultRouteParameters in AbstractAdmin…
Browse files Browse the repository at this point in the history
…Controller
  • Loading branch information
ambroisemaupate committed Jun 13, 2024
1 parent c97cfbe commit 899b397
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lib/Rozier/src/Controllers/AbstractAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,14 @@ protected function getDefaultOrder(Request $request): array
*/
abstract protected function getDefaultRouteName(): string;

/**
* @return array<string, string|int|null>
*/
protected function getDefaultRouteParameters(): array
{
return [];
}

/**
* @return string
*/
Expand Down Expand Up @@ -475,7 +483,10 @@ protected function getEditRouteParameters(PersistableInterface $item): array
*/
protected function getPostDeleteResponse(PersistableInterface $item): Response
{
return $this->redirect($this->urlGenerator->generate($this->getDefaultRouteName()));
return $this->redirect($this->urlGenerator->generate(
$this->getDefaultRouteName(),
$this->getDefaultRouteParameters()
));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ protected function bulkAction(
}
}
$this->em()->flush();
return $this->redirect($this->urlGenerator->generate($this->getDefaultRouteName()));
return $this->redirect($this->urlGenerator->generate(
$this->getDefaultRouteName(),
$this->getDefaultRouteParameters()
));
}
}

Expand All @@ -164,6 +167,7 @@ protected function bulkAction(

public function bulkDeleteAction(Request $request): Response
{
$this->additionalAssignation($request);
return $this->bulkAction(
$request,
$this->getRequiredDeletionRole(),
Expand All @@ -185,6 +189,7 @@ function (PersistableInterface $item) {

public function bulkPublishAction(Request $request): Response
{
$this->additionalAssignation($request);
return $this->bulkAction(
$request,
$this->getRequiredRole(),
Expand All @@ -206,6 +211,7 @@ function (PersistableInterface $item) {

public function bulkUnpublishAction(Request $request): Response
{
$this->additionalAssignation($request);
return $this->bulkAction(
$request,
$this->getRequiredRole(),
Expand Down
5 changes: 4 additions & 1 deletion lib/Rozier/src/Controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ public function triggerAction(Request $request, string $id): Response
);
$this->publishConfirmMessage($request, $msg, $item);

return $this->redirect($this->urlGenerator->generate($this->getDefaultRouteName()));
return $this->redirect($this->urlGenerator->generate(
$this->getDefaultRouteName(),
$this->getDefaultRouteParameters()
));
} catch (TooManyWebhookTriggeredException $e) {
$form->addError(new FormError('webhook.too_many_triggered_in_period', null, [
'%time%' => $e->getDoNotTriggerBefore()->format('H:i:s')
Expand Down

0 comments on commit 899b397

Please sign in to comment.