custom/plugins/AcrisFaqCS/src/Storefront/Page/FaqDetail/FaqDetailPageLoader.php line 34

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Acris\Faq\Storefront\Page\FaqDetail;
  3. use Acris\Faq\Components\Faq\FaqService;
  4. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  5. use Shopware\Storefront\Page\GenericPageLoaderInterface;
  6. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  7. use Symfony\Component\HttpFoundation\Request;
  8. class FaqDetailPageLoader
  9. {
  10. private EventDispatcherInterface $eventDispatcher;
  11. private GenericPageLoaderInterface $genericPageLoader;
  12. private FaqService $faqService;
  13. public function __construct(
  14. EventDispatcherInterface $eventDispatcher,
  15. GenericPageLoaderInterface $genericPageLoader,
  16. FaqService $faqService
  17. )
  18. {
  19. $this->eventDispatcher = $eventDispatcher;
  20. $this->genericPageLoader = $genericPageLoader;
  21. $this->faqService = $faqService;
  22. }
  23. public function load(string $faqId, Request $request, SalesChannelContext $salesChannelContext): FaqDetailPage
  24. {
  25. $page = $this->genericPageLoader->load($request, $salesChannelContext);
  26. $page = FaqDetailPage::createFrom($page);
  27. $faq = $this->faqService->getFaqById($faqId, $salesChannelContext, $request);
  28. // load cmsPages
  29. //$faq = $this->faqService->getFaqById($faqId, $salesChannelContext, $request);
  30. $page->setFaq($faq);
  31. $this->eventDispatcher->dispatch(
  32. new FaqDetailPageLoadedEvent($page, $salesChannelContext, $request)
  33. );
  34. return $page;
  35. }
  36. }