src/Storefront/Pagelet/Footer/FooterPageletLoader.php line 29

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Pagelet\Footer;
  3. use Shopware\Core\Content\Category\Service\NavigationLoaderInterface;
  4. use Shopware\Core\Framework\Log\Package;
  5. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  6. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  7. use Symfony\Component\HttpFoundation\Request;
  8. #[Package('storefront')]
  9. class FooterPageletLoader implements FooterPageletLoaderInterface
  10. {
  11.     /**
  12.      * @internal
  13.      */
  14.     public function __construct(private readonly EventDispatcherInterface $eventDispatcher, private readonly NavigationLoaderInterface $navigationLoader)
  15.     {
  16.     }
  17.     public function load(Request $requestSalesChannelContext $salesChannelContext): FooterPagelet
  18.     {
  19.         $footerId $salesChannelContext->getSalesChannel()->getFooterCategoryId();
  20.         $tree null;
  21.         if ($footerId) {
  22.             $navigationId $request->get('navigationId'$footerId);
  23.             $tree $this->navigationLoader->load($navigationId$salesChannelContext$footerId);
  24.         }
  25.         $pagelet = new FooterPagelet($tree);
  26.         $this->eventDispatcher->dispatch(
  27.             new FooterPageletLoadedEvent($pagelet$salesChannelContext$request)
  28.         );
  29.         return $pagelet;
  30.     }
  31. }