<?php 
 
namespace App\Controller; 
 
use Doctrine\ORM\EntityManagerInterface; 
use Gedmo\Loggable\Entity\LogEntry; 
use Gedmo\Loggable\Entity\Repository\LogEntryRepository; 
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; 
use Symfony\Component\HttpFoundation\Response; 
use Symfony\Component\Routing\Annotation\Route; 
use Xearts\Bundle\TaobaoDaikoBundle\Entity\Feature; 
use Xearts\Bundle\TaobaoDaikoBundle\Entity\Information; 
use Xearts\Bundle\TaobaoDaikoBundle\Repository\FeatureRepository; 
use Xearts\Bundle\TaobaoDaikoBundle\Repository\InformationRepository; 
use Xearts\Bundle\TaobaoDaikoBundle\Repository\PageContentRepository; 
 
class DefaultController extends AbstractController 
{ 
    /** 
     * @Route("/") 
     */ 
    public function index(EntityManagerInterface $entityManager): Response 
    { 
        $informations = $this->getInformationRepository()->findForFront(1); 
        /** @var Information $information */ 
        $information = null; 
        if ($informations) { 
            $information = $informations[0]; 
        } 
 
 
        // 特徴を取得する 
        $feature = null; 
 
        $featureRepository = $entityManager->getRepository(Feature::class); 
 
        $feature = $featureRepository->findOneForFront(); 
 
        return $this->render('default/index.html.twig', [ 
            'information' => $information, 
            'feature' => $feature, 
        ]); 
    } 
 
    /** 
     * @Route("/sample/") 
     */ 
    public function sample(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_sample'); 
        return $this->render('default/sample.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/about/") 
     */ 
    public function about(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_about'); 
        return $this->render('default/about.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/fee/") 
     */ 
    public function fee(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_fee'); 
        return $this->render('default/fee.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/guide/") 
     */ 
    public function guide(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_guide'); 
        return $this->render('default/guide.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/agree/") 
     */ 
    public function agree(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_agree'); 
        return $this->render('default/agree.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/holiday/") 
     */ 
    public function holiday(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_holiday'); 
        return $this->render('default/holiday.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/privacy/") 
     */ 
    public function privacy(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_privacy'); 
        return $this->render('default/privacy.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/company/") 
     */ 
    public function company(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_company'); 
        return $this->render('default/company.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/aosct/") 
     */ 
    public function aosct(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_aosct'); 
        return $this->render('default/aosct.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/postage/") 
     */ 
    public function postage(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_postage'); 
        return $this->render('default/postage.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
 
    /** 
     * @Route("/special/") 
     */ 
    public function special(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_special'); 
        return $this->render('default/special.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/amazon-fba/") 
     */ 
    public function  amazonFba(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_amazonfba'); 
        return $this->render('default/amazon_fba.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/new-function/") 
     */ 
    public function  newfunction(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName('app_default_newfunction'); 
        return $this->render('default/newfunction.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @Route("/chrome-extension") 
     */ 
    public function  chromeExtension(): Response 
    { 
        //ページコンテンツを取得する 
        $pageContent = $this->getPageContentRepository()->findOneByRouteName("/chrome-extension/"); 
        return $this->render('default/chromeextension.html.twig', [ 
            'pageContent' => $pageContent, 
        ]); 
    } 
 
    /** 
     * @return \Xearts\Bundle\TaobaoDaikoBundle\Repository\InformationRepository 
     */ 
    private function getInformationRepository(): InformationRepository 
    { 
        return $this->getDoctrine()->getRepository('XeartsTaobaoDaikoBundle:Information'); 
    } 
 
    /** 
     * @return \Xearts\Bundle\TaobaoDaikoBundle\Repository\FeatureRepository 
     */ 
    private function getFeatureRepository(): FeatureRepository 
    { 
        return $this->getDoctrine()->getRepository('XeartsTaobaoDaikoBundle:Feature'); 
    } 
 
    /** 
     * @return \Xearts\Bundle\TaobaoDaikoBundle\Repository\PageContentRepository 
     */ 
    private function getPageContentRepository(): PageContentRepository 
    { 
        return $this->getDoctrine()->getRepository('XeartsTaobaoDaikoBundle:PageContent'); 
    } 
 
    private function getLogEntryRepository(): LogEntryRepository 
    { 
        return $this->getDoctrine()->getRepository(LogEntry::class); 
    } 
}