Skip to content

Commit

Permalink
Use native Sylius method to get taxon's full name
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran committed Apr 9, 2024
1 parent 72762e7 commit 6bcf015
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions src/Provider/TaxonUrlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getItems(string $locale): array
continue;
}
$items[] = [
'name' => $this->getTaxonFullName($taxon),
'name' => $taxon->getFullname(' > '),
'value' => $this->router->generate('sylius_shop_product_index', ['slug' => $taxon->getSlug(), '_locale' => $locale]),
];
}
Expand All @@ -61,20 +61,4 @@ public function getItems(string $locale): array

return $items;
}

private function getTaxonFullName(TaxonInterface $taxon): string
{
$fullName = (string) $taxon->getName();
$parent = $taxon->getParent();
while (null !== $parent) {
/** @var TaxonInterface $parent */
if ($parent->isRoot()) {
break;
}
$fullName = $parent->getName() . ' > ' . $fullName;
$parent = $parent->getParent();
}

return $fullName;
}
}

0 comments on commit 6bcf015

Please sign in to comment.