app/Plugin/SearchPlus/Controller/Block/SearchDetailController.php line 41

Open in your IDE?
  1. <?php
  2. /*
  3. * Plugin Name : SearchPlus
  4. *
  5. * Copyright (C) BraTech Co., Ltd. All Rights Reserved.
  6. * http://www.bratech.co.jp/
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Plugin\SearchPlus\Controller\Block;
  12. use Eccube\Controller\AbstractController;
  13. use Eccube\Form\Type\SearchProductBlockType;
  14. use Plugin\SearchPlus\Service\SearchPlusService;
  15. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\RequestStack;
  19. class SearchDetailController extends AbstractController
  20. {
  21.     protected $requestStack;
  22.     private $searchPlusService;
  23.     public function __construct(
  24.             RequestStack $requestStack,
  25.             SearchPlusService $searchPlusService
  26.             )
  27.     {
  28.         $this->searchPlusService $searchPlusService;
  29.         $this->requestStack $requestStack;
  30.     }
  31.     /**
  32.      * @Route("/block/search_detail", name="block_search_detail")
  33.      * @Template("Block/search_detail.twig")
  34.      */
  35.     public function index(Request $request)
  36.     {
  37.         $ProductItems = [];
  38.         if($this->searchPlusService->checkInstallPlugin('ProductPlus')){
  39.             $productItemRepository $this->entityManager->getRepository('Plugin\ProductPlus\Entity\ProductItem');
  40.             if(method_exists('Plugin\ProductPlus\Entity\ProductItem''setSearchFlg')){
  41.                 $ProductItems $productItemRepository->findBy(['search_flg' => true],['sort_no' => 'DESC']);
  42.             }else{
  43.                 $ProductItems $productItemRepository->findBy([],['sort_no' => 'DESC']);
  44.             }
  45.         }
  46.         $builder $this->formFactory
  47.             ->createNamedBuilder(''SearchProductBlockType::class)
  48.             ->setMethod('GET');
  49.         $request $this->requestStack->getMasterRequest();
  50.         $form $builder->getForm();
  51.         $form->handleRequest($request);
  52.         return [
  53.             'ProductItems' => $ProductItems,
  54.             'form' => $form->createView(),
  55.         ];
  56.     }
  57. }