app/Plugin/EtunaCheckedItem/Controller/EtunaCheckedItemController.php line 34

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) Takashi Otaki All Rights Reserved.
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Plugin\EtunaCheckedItem\Controller;
  11. use Plugin\EtunaCheckedItem\Repository\EtunaCheckedItemConfigRepository;
  12. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Eccube\Repository\ProductRepository;
  16. /**
  17.  * Class EtunaCheckedItemController front.
  18.  */
  19. class EtunaCheckedItemController extends \Eccube\Controller\AbstractController
  20. {
  21.     /**
  22.      * @Route("/block/etuna_checked_item", name="block_etuna_checked_item")
  23.      * @Template("Block/etuna_checked_item.twig")
  24.      *
  25.      * @param Request $request
  26.      * @param EtunaCheckedItemConfigRepository $configRepository
  27.      * @param ProductRepository $productRepository
  28.      */
  29.     public function index(Request $requestEtunaCheckedItemConfigRepository $configRepositoryProductRepository $productRepository)
  30.     {
  31.         $Config $configRepository->get();
  32.         $checkedItemArray = array();
  33.         $checkedItems $request->cookies->get('CheckedItemIds');
  34.         $checkedItemsArray array_reverse(explode("_"$checkedItems));
  35.         foreach ($checkedItemsArray as $checkedItemsId) {
  36.             $qb $productRepository->createQueryBuilder('p')
  37.                 ->where('p.id = :id')
  38.                 ->andWhere('p.Status = 1')
  39.                 ->setParameter('id'$checkedItemsId)
  40.             ;
  41.             $CheckedItem $qb->getQuery()->getResult();
  42.             if ($CheckedItem != null) {
  43.                 $checkedItemArray[] = $CheckedItem;
  44.             }
  45.         }
  46.         return [
  47.             'Config' => $Config,
  48.             'CheckedItem' => $checkedItemArray,
  49.         ];
  50.     }
  51. }