Skip to content

Commit

Permalink
[FrontendBundle] remove container injection and use router directly
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfaffenbauer committed May 4, 2023
1 parent 7f966ab commit e1ee76a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
- '@Pimcore\Model\Document\Service'
- '@CoreShop\Component\Core\Context\ShopperContextInterface'
- '@Symfony\Component\HttpFoundation\RequestStack'
- '@service_container'
- '@router'
tags:
- { name: twig.extension }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RouterInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

Expand All @@ -37,7 +38,7 @@ public function __construct(
private Document\Service $documentService,
private ShopperContextInterface $shopperContext,
private RequestStack $requestStack,
protected ContainerInterface $container,
private RouterInterface $router,
) {
}

Expand Down Expand Up @@ -95,7 +96,7 @@ public function getLocalizedLinks(Document $document): array
if ( str_contains($staticRoute->getVariables(), '_locale') ) {
$params = ['_locale' => $language];
}
$link = $this->container->get('router')->generate($route, $params);
$link = $this->router->generate($route, $params);
} else {
if ( isset($translations[$language]) ) {
$localizedDocument = Document::getById($translations[$language]);
Expand Down

0 comments on commit e1ee76a

Please sign in to comment.