src/Eccube/Controller/Block/PanNaviController.php line 32

Open in your IDE?
  1. <?php
  2. namespace Eccube\Controller\Block;
  3. use Eccube\Controller\AbstractController;
  4. use Eccube\Repository\PageRepository;
  5. use Eccube\Repository\ProductRepository;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\HttpFoundation\RequestStack;
  9. class PanNaviController extends AbstractController
  10. {
  11.     protected $pageRepository;
  12.     protected $productRepository;
  13.     protected $requestStack;
  14.     public function __construct(
  15.       PageRepository $pageRepository,
  16.       ProductRepository $productRepository,
  17.       RequestStack $requestStack
  18.     ) {
  19.       $this->pageRepository $pageRepository;
  20.       $this->productRepository $productRepository;
  21.       $this->requestStack $requestStack;
  22.     }
  23.     /**
  24.      * @Route("/block/pan_navi", name="block_pan_navi", methods={"GET"})
  25.      */
  26.     public function index()
  27.     {
  28.       $mainRequest $this->requestStack->getMainRequest();
  29.       $route $mainRequest->attributes->get('_route');
  30.       if($route == "user_data") {
  31.         $tmp explode("/"$_SERVER['REQUEST_URI']);
  32.         if (!empty($tmp[2])) {
  33.           $route $tmp[2];
  34.         }
  35.       }
  36.       $page $this->pageRepository->findOneBy([
  37.         'url' => trim($route),
  38.       ]);
  39.       $title "";
  40.       $sub_title "";
  41.       if(!empty($page)){
  42.         $title $page->getName();
  43.       }
  44.       $plaza_flg false;
  45.       if($route == "product_detail"){
  46.           $plaza_flg true;
  47.         $sub_title "商品一覧";
  48.         $id $mainRequest->attributes->get('id');
  49.         $product $this->productRepository->find($id);
  50.         if(!empty($product)){
  51.           $title $product->getName();
  52.         }
  53.       }
  54.       if($route == "plaza_product_detail"){
  55.           $plaza_flg true;
  56.         $sub_title "プラザ商品一覧";
  57.         $id $mainRequest->attributes->get('id');
  58.         $product $this->productRepository->find($id);
  59.         if(!empty($product)){
  60.           $title $product->getName();
  61.         }
  62.       }
  63.       return $this->render('Block/pan_navi.twig', [
  64.         "title" => $title,
  65.         "sub_title" => $sub_title,
  66.           "plaza_flg" => $plaza_flg,
  67.       ]);
  68.     }
  69. }