Skip to content

Commit

Permalink
Fixed generateSkipToken action with pretty URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtronics committed Jan 8, 2025
1 parent 2e26a57 commit d69e7ac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Controller/Admin/DepartmentCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use App\Entity\DepartmentTypes;
use App\Services\EmailConfirmation\ConfirmationTokenGenerator;
use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Attribute\AdminAction;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
Expand Down Expand Up @@ -62,6 +63,7 @@ public function configureCrud(Crud $crud): Crud
->setSearchFields(['id', 'name', 'type', 'comment']);
}

#[AdminAction(routePath: '/action-generated-skip-token', routeName: 'admin_department_generate_skip_token', methods: ['GET', 'POST'])]
public function generateSkipToken(AdminContext $context): Response
{
$this->denyAccessUnlessGranted('ROLE_EDIT_ORGANISATIONS');
Expand All @@ -73,7 +75,7 @@ public function generateSkipToken(AdminContext $context): Response
$department->addSkipBlockedValidationToken($this->tokenGenerator->getToken());
$this->entityManager->flush();

return $this->redirect($context->getReferrer() ?? '/admin');
return $this->redirectToRoute('admin_department_detail', ['entityId' => $department->getId()]);
}

public function configureActions(Actions $actions): Actions
Expand Down

0 comments on commit d69e7ac

Please sign in to comment.