app/Customize/Controller/MakerController.php line 40

Open in your IDE?
  1. <?php
  2. namespace Customize\Controller;
  3. use Eccube\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  9. use Plugin\Maker42\Entity\Maker;
  10. use Plugin\Maker42\Repository\MakerRepository;
  11. use Customize\Repository\MakerListRepository;
  12. class MakerController extends AbstractController
  13. {
  14.      
  15.     /**
  16.      * @param MakerRepository $makerRepository
  17.      */
  18.     /**
  19.      * @param MakerListRepository $makerListRepository
  20.      */
  21.     public function __construct(
  22.         MakerRepository $makerRepository,
  23.         MakerListRepository $makerListRepository) {
  24.         $this->makerRepository $makerRepository;
  25.         $this->makerListRepository $makerListRepository;
  26.     }
  27.     /**
  28.      * @Method("GET")
  29.      * @Route("/maker/", name="maker")
  30.      * @Template("Maker/maker.twig")
  31.      */
  32.     public function index()
  33.     {
  34.         $makers $this->makerRepository->findBy([], ['sort_no' => 'DESC']);
  35.         return [
  36.             'Makers' => $makers,
  37.         ];
  38.     }
  39.     /**
  40.      * @Method("GET")
  41.      * @Route("/maker/search", name="maker_search")
  42.      * @Template("Maker/search.twig")
  43.      */
  44.     public function makerSearch()
  45.     {
  46.         if(!empty($_GET['kana'])){
  47.             $mode 1;
  48.             $kana_key $_GET['kana'];
  49.             $makers $this->makerListRepository->makerSearch($mode,$_GET['kana']);
  50.             $maker_count $this->makerListRepository->makerSearchCount($mode,$_GET['kana']);
  51.         }else{
  52.             $mode 2;
  53.             $kana_array = [
  54.                 "あ" => ['あ','い','う','え','お'],
  55.                 "か" => ['か','き','く','け','こ'],
  56.                 "さ" => ['さ','し','す','せ','そ'],
  57.                 "た" => ['た','ち','つ','て','と'],
  58.                 "な" => ['な','に','ぬ','ね','の'],
  59.                 "は" => ['は','ひ','ふ','へ','ほ'],
  60.                 "ま" => ['ま','み','む','め','も'],
  61.                 "や" => ['や','ゆ','よ'],
  62.                 "ら" => ['ら','り','る','れ','ろ'],
  63.                 "わ" => ['わ','を','ん'],
  64.             ];
  65.             $kana_row "";
  66.             if(!empty($kana_array)){
  67.                 foreach($kana_array as $kana_key => $kana_val){
  68.                     if($kana_key == $_GET['kana_row']){
  69.                         $kana_row $kana_val;
  70.                     }
  71.                 }
  72.             }
  73.             $makers $this->makerListRepository->makerSearch($mode,$kana_row);
  74.             $maker_count $this->makerListRepository->makerSearchCount($mode,$kana_row);
  75.         }
  76.         return [
  77.             'makers' => $makers,
  78.             'maker_count' => $maker_count
  79.         ];
  80.     }
  81. }