From c9ed368cf846cd6d0447891f9482ecac4561d1cf Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Tue, 31 Dec 2024 10:11:02 +0100 Subject: [PATCH] [CoreBundle] allow to pass site to link generation --- .../Pimcore/LinkGenerator/DataObjectLinkGenerator.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/CoreShop/Bundle/CoreBundle/Pimcore/LinkGenerator/DataObjectLinkGenerator.php b/src/CoreShop/Bundle/CoreBundle/Pimcore/LinkGenerator/DataObjectLinkGenerator.php index 87e221f7a9..dd1e37a1ed 100644 --- a/src/CoreShop/Bundle/CoreBundle/Pimcore/LinkGenerator/DataObjectLinkGenerator.php +++ b/src/CoreShop/Bundle/CoreBundle/Pimcore/LinkGenerator/DataObjectLinkGenerator.php @@ -20,7 +20,9 @@ use CoreShop\Component\Pimcore\DataObject\AbstractSluggableLinkGenerator; use CoreShop\Component\Pimcore\DataObject\InheritanceHelper; +use Pimcore\Model\DataObject\Concrete; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Webmozart\Assert\Assert; class DataObjectLinkGenerator extends AbstractSluggableLinkGenerator { @@ -33,6 +35,8 @@ public function __construct( public function generate(object $object, array $params = []): string { + Assert::isInstanceOf($object, Concrete::class); + $locale = $params['_locale'] ?? null; $name = InheritanceHelper::useInheritedValues(function () use ($object, $locale) { @@ -56,6 +60,10 @@ public function generate(object $object, array $params = []): string $params['referenceType'] = UrlGeneratorInterface::ABSOLUTE_PATH; } + if (isset($params['site'])) { + $routeParams['site'] = $params['site']; + } + return $this->urlGenerator->generate($params['route'] ?? $this->routeName, $routeParams, $params['referenceType']); } }