<?php
namespace Boldr\Shop\ShopBundle\Link;
use Boldr\Cms\CmsBundle\Link\{ LinkProviderInterface, LinkGeneratorInterface, LinkInterface };
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class ShopLinks implements LinkProviderInterface, LinkGeneratorInterface
{
private const ROUTES = [
'shop' => 'shop_shop',
];
private UrlGeneratorInterface $urlGenerator;
public function __construct(UrlGeneratorInterface $urlGenerator)
{
$this->urlGenerator = $urlGenerator;
}
public function getName(): string { return 'Shop'; }
public function getLinks(?string $search = null, int $amount): iterable
{
yield new ShopLink('shop');
}
/**
* @param ShopLink $link
*/
public function generateLinkUrl(LinkInterface $link): string
{
return $this->urlGenerator->generate(self::ROUTES[$link->getLink()]);
}
}