fix: route EbayAspectImportController redirects through AdminUrlGenerator

Plain redirectToRoute() bypasses EasyAdmin's AdminRouterSubscriber, so
the admin context (ea.i18n etc.) was never set and the EasyAdmin layout
threw "Impossible to access i18n on null". Using AdminUrlGenerator wraps
the redirect URL in the EasyAdmin routing layer, keeping context alive.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Simon Kuehn 2026-05-18 20:15:31 +00:00
parent 53e2d36574
commit 0fdb4979c1

View file

@ -10,6 +10,7 @@ use App\Domain\Article\AttributeType;
use App\Domain\Article\Repository\ArticleTypeRepositoryInterface; use App\Domain\Article\Repository\ArticleTypeRepositoryInterface;
use App\Infrastructure\Channel\Ebay\EbayTaxonomyService; use App\Infrastructure\Channel\Ebay\EbayTaxonomyService;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -25,6 +26,7 @@ final class EbayAspectImportController extends AbstractController
private readonly ArticleTypeRepositoryInterface $articleTypeRepo, private readonly ArticleTypeRepositoryInterface $articleTypeRepo,
private readonly EbayTaxonomyService $taxonomy, private readonly EbayTaxonomyService $taxonomy,
private readonly EntityManagerInterface $em, private readonly EntityManagerInterface $em,
private readonly AdminUrlGenerator $adminUrlGenerator,
) { ) {
} }
@ -106,7 +108,9 @@ final class EbayAspectImportController extends AbstractController
$this->em->flush(); $this->em->flush();
} }
return $this->redirectToRoute('admin_ebay_aspect_import', ['id' => $articleType->getId()->toRfc4122()]); return $this->redirect(
$this->adminUrlGenerator->setRoute('admin_ebay_aspect_import', ['id' => $articleType->getId()->toRfc4122()])->generateUrl()
);
} }
private function handleImport(Request $request, ArticleType $articleType): Response private function handleImport(Request $request, ArticleType $articleType): Response