Skip to content

Commit

Permalink
void incorrect locale while getting fullname in the root taxon
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran committed Jun 19, 2024
1 parent c79b19c commit 3c7f09c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Provider/TaxonUrlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ protected function addItemFromResult(object $result, string $locale): void
Assert::isInstanceOf($result, TaxonInterface::class);
/** @var TaxonInterface $result */
$result->setCurrentLocale($locale);

// Avoid incorrect locale while getting fullname in the root taxon
if (!$result->isRoot()) {
$result->getRoot()->setCurrentLocale($locale);

Check failure on line 69 in src/Provider/TaxonUrlProvider.php

View workflow job for this annotation

GitHub Actions / php (8.1)

Cannot call method setCurrentLocale() on Sylius\Component\Taxonomy\Model\TaxonInterface|null.

Check failure on line 69 in src/Provider/TaxonUrlProvider.php

View workflow job for this annotation

GitHub Actions / php (8.2)

Cannot call method setCurrentLocale() on Sylius\Component\Taxonomy\Model\TaxonInterface|null.
}

$this->addItem(
(string) $result->getFullname(' > '),
$this->router->generate('sylius_shop_product_index', ['slug' => $result->getSlug(), '_locale' => $locale])
Expand Down

0 comments on commit 3c7f09c

Please sign in to comment.