diff --git a/src/CoreShop/Component/Pimcore/Event/SlugGenerationEvent.php b/src/CoreShop/Component/Pimcore/Event/SlugGenerationEvent.php index f89ead1bd5..7a5125744f 100644 --- a/src/CoreShop/Component/Pimcore/Event/SlugGenerationEvent.php +++ b/src/CoreShop/Component/Pimcore/Event/SlugGenerationEvent.php @@ -29,6 +29,7 @@ public function __construct( protected string $slug, protected ?string $suffix = null, protected ?Site $site = null, + protected ?string $locale = null, ) { } @@ -56,4 +57,9 @@ public function getSite(): ?Site { return $this->site; } + + public function getLocale(): ?string + { + return $this->locale; + } } diff --git a/src/CoreShop/Component/Pimcore/Slug/DataObjectSiteSlugGenerator.php b/src/CoreShop/Component/Pimcore/Slug/DataObjectSiteSlugGenerator.php index 1f4afe08a0..3c1d8c155c 100644 --- a/src/CoreShop/Component/Pimcore/Slug/DataObjectSiteSlugGenerator.php +++ b/src/CoreShop/Component/Pimcore/Slug/DataObjectSiteSlugGenerator.php @@ -34,7 +34,7 @@ public function __construct( public function generateSlugsForSite(SluggableInterface $sluggable, string $locale, ?Site $site = null): string { $slug = $this->slugger->slug($sluggable, $locale, null); - $slug = $this->dispatchSlugEvent($sluggable, $slug, null, $site); + $slug = $this->dispatchSlugEvent($sluggable, $slug, null, $site, $locale); $i = 1; @@ -47,7 +47,7 @@ public function generateSlugsForSite(SluggableInterface $sluggable, string $loca } $slug = $this->slugger->slug($sluggable, $locale, (string) $i); - $slug = $this->dispatchSlugEvent($sluggable, $slug, (string) $i, $site); + $slug = $this->dispatchSlugEvent($sluggable, $slug, (string) $i, $site, $locale); ++$i; } @@ -55,9 +55,9 @@ public function generateSlugsForSite(SluggableInterface $sluggable, string $loca return $slug; } - private function dispatchSlugEvent(SluggableInterface $sluggable, string $slug, string $prefix = null, ?Site $site = null) + private function dispatchSlugEvent(SluggableInterface $sluggable, string $slug, string $prefix = null, ?Site $site = null, ?string $locale = null) { - $event = new SlugGenerationEvent($sluggable, $slug, $prefix, $site); + $event = new SlugGenerationEvent($sluggable, $slug, $prefix, $site, $locale); $this->eventDispatcher->dispatch($event); return $event->getSlug();