app/Plugin/RefineBreadcrumbsBlock42/Controller/RefineBreadcrumbsBlock42.php line 16

Open in your IDE?
  1. <?php
  2. namespace Plugin\RefineBreadcrumbsBlock42\Controller;
  3. use Eccube\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  7. class RefineBreadcrumbsBlock42 extends AbstractController
  8. {
  9.     /**
  10.      * @Route("/block/refine_breadcrumbs_block42", name="block_refine_breadcrumbs_block42")
  11.      * @Template("Block/refine_breadcrumbs_block42.twig")
  12.      */
  13.     public function index(Request $request)
  14.     {
  15.         $uri $_SERVER['REQUEST_URI'];
  16.         $parse_uriparse_url($uriPHP_URL_PATH);
  17.         // 商品一覧画面のカテゴリIDを取得
  18.         $is_category_id = isset($_GET['category_id']);
  19.         if ($is_category_id) {
  20.             $category_id $_GET['category_id'];
  21.         } else {
  22.             $category_id false;
  23.         };
  24.         // 商品詳細ページ
  25.         $products_detail_page false;
  26.         $products_detail_id false;
  27.         if (strpos($uri'/products/detail/') !== false) {
  28.             $products_detail_page true;
  29.             $products_detail_id str_replace('/products/detail/'''$parse_uri);
  30.         };
  31.         // お知らせ(news)ページ
  32.         $news_page false;
  33.         $news_id false;
  34.         if (strpos($uri'/news/') !== false) {
  35.             $news_page true;
  36.             $news_id str_replace('/news/'''$parse_uri);
  37.         };
  38.         // お知らせ一覧(news_list)ページ
  39.         $news_list_page false;
  40.         if (strpos($uri'/news/') !== false && !preg_match('/news\/\d+/'$uri)) {
  41.             $news_list_page true;
  42.         };
  43.         $RefineBreadcrumbsBlock = [
  44.             'categoryId' => $category_id,
  45.             'ProductsDetailPage' => $products_detail_page,
  46.             'ProductsDetailId' => $products_detail_id,
  47.             'uri' => $uri,
  48.             'NewsPage' => $news_page,
  49.             'NewsId' => $news_id,
  50.             'NewsListPage' => $news_list_page,
  51.         ];
  52.         return [
  53.             'RefineBreadcrumbsBlock' => $RefineBreadcrumbsBlock,
  54.         ];
  55.     }
  56. }