src/Controller/SpController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Pimcore\Model\DataObject\ServiceProvider;
  4. use Pimcore\Model\DataObject\Folder;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use App\Website\LinkGenerator\SpLinkGenerator;
  8. use App\Website\Navigation\BreadcrumbHelperService;
  9. use Knp\Component\Pager\PaginatorInterface;
  10. use Pimcore\Twig\Extension\Templating\HeadTitle;
  11. use Pimcore\Twig\Extension\Templating\Placeholder;
  12. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  13. use Symfony\Component\Routing\Annotation\Route;
  14.   
  15. class SpController extends BaseController
  16. {
  17.     const SP_DEFAULT_DOCUMENT_PROPERTY_NAME 'sp_default_document';
  18.   
  19.      /**
  20.      * @param Request $request
  21.      *
  22.      * @return Response
  23.      *
  24.      * @throws \Exception
  25.      */
  26.      public function listingAction(Request $requestPaginatorInterface $paginator)
  27.     {
  28.         $spListing = new ServiceProvider\Listing();
  29.         $spListing->setOrderKey('title');
  30.         $spListing->setOrder('ASC');
  31.         $spMembers Folder::getById(1846);
  32.         $spObservers Folder::getById(1847);
  33.         $spPartners Folder::getById(1848);
  34.         $paginator $paginator->paginate(
  35.             $spListing,
  36.             $request->get('page'1),
  37.             6
  38.         );
  39.         return $this->render('sp/listing.html.twig', [
  40.             'members' => $spMembers,
  41.             'observers' => $spObservers,
  42.             'partners' => $spPartners
  43.         ]);
  44.       //  return $this->render('sp/listing.html.twig', ['spListing' => $spListing]);
  45.     }
  46.     /**
  47.       * @Route("{path}/{sptitle}-spid{sp}", name="sp-detail", defaults={"path"=""}, requirements={"path"=".*?", "sptitle"="[\w-]+", "sp"="\d+"})
  48.      *
  49.      * @param Request $request
  50.      * @param HeadTitle $headTitleHelper
  51.      * @param Placeholder $placeholderHelper
  52.      * @param SpLinkGenerator $spLinkGenerator
  53.      * @param BreadcrumbHelperService $breadcrumbHelperService
  54.      *
  55.      * @return Response
  56.      */
  57.     public function detailAction(Request $requestHeadTitle $headTitleHelperPlaceholder $placeholderHelperSpLinkGenerator $spLinkGeneratorBreadcrumbHelperService $breadcrumbHelperService)
  58.     {
  59.         $sp ServiceProvider::getById($request->get('sp'));
  60.         //$sp = ServiceProvider::getById(4);
  61.         if (!($sp instanceof ServiceProvider && ($sp->isPublished() || $this->verifyPreviewRequest($request$sp)))) {
  62.             throw new NotFoundHttpException('Sp not found.');
  63.         }
  64.         $headTitleHelper($sp->getTitle());
  65.         $breadcrumbHelperService->enrichSpPage($sp);
  66.         $placeholderHelper('canonical')->set($spLinkGenerator->generate($sp, ['document' => $this->document->getProperty(self::SP_DEFAULT_DOCUMENT_PROPERTY_NAME)]));
  67.         return $this->render('sp/detail.html.twig', [
  68.             'sp' => $sp
  69.         ]);
  70.     }
  71. }