src/Gh/FrontBundle/Controller/SidebarController.php line 160

Open in your IDE?
  1. <?php
  2. namespace Gh\FrontBundle\Controller;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Gh\DatabaseBundle\Entity\GhCard;
  5. use Gh\DatabaseBundle\Entity\GhTeam;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  7. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  8. /**
  9.  * In this controller, a method is created for each component of the right sidebar.
  10.  * 
  11.  * @author jmboyer
  12.  */
  13. class SidebarController extends Controller
  14. {
  15.     /**
  16.      * These constants are used for similarCards and linkedCards sidebars. 
  17.      */
  18.     const CARDS_LIST_SIMILAR 10;
  19.     const CARDS_LIST_LINKED 20;
  20.     /**
  21.      * This component is the Similar games block in the sidebar (displayed in cards layout).
  22.      *
  23.      * @param GhCard|null $card
  24.      * @return array
  25.      * @Template("@GhFront/sidebar/cards_list.html.twig")
  26.      */
  27.     public function similarCardsAction(?GhCard $card): array {
  28.         $em $this->getDoctrine()->getManager();
  29.         $similarCards $em->getRepository('GhDatabaseBundle:GhCard')->getSimilarCards($card$this->container);
  30.         
  31.         return array('cardsList' => $similarCards'mode' => self::CARDS_LIST_SIMILAR);
  32.     }
  33.     /**
  34.      * This component is the Linked cards block in the sidebar (displayed in news).
  35.      *
  36.      * @param GhCard[] $cardsList
  37.      * @return array
  38.      * @Template("@GhFront/sidebar/cards_list.html.twig")
  39.      */
  40.     public function linkedCardsAction($cardsList): array {
  41.         return array('cardsList' => $cardsList'mode' => self::CARDS_LIST_LINKED);
  42.     }
  43.     /**
  44.      * This component is the Card block in the sidebar (displayed in news).
  45.      *
  46.      * @param GhCard[] $card This parameter is an array because a card can exist on multiple consoles.
  47.      * @return array
  48.      * @Template()
  49.      */
  50.     public function cardAction($card): array {
  51.         $em $this->getDoctrine()->getManager();
  52.         // Get card aliases
  53.         $cardAliases $em->getRepository('GhDatabaseBundle:GhCardAlias')->findByCardid($card[0]->getId());
  54.         // Get the material cards
  55.         $cardMaterialList $em->getRepository('GhDatabaseBundle:GhCardMaterial')->getMaterialCards($card[0]);
  56.         $cardMaterialsMandatory = array();
  57.         $cardMaterialsNotMandatory = array();
  58.         foreach ($cardMaterialList as $cardMaterial) {
  59.             if ($cardMaterial->getIsmandatory()) {
  60.                 $cardMaterialsMandatory[] = $cardMaterial;
  61.             } else {
  62.                 $cardMaterialsNotMandatory[] = $cardMaterial;
  63.             }
  64.         }
  65.         // Get the distribution methods
  66.         $cardDistributionMethods $em->getRepository('GhDatabaseBundle:GhCardDistributionMethod')->getByCard($card[0]);
  67.         return array(
  68.             'card' => $card[0],
  69.             'cardConsoles' => $card,
  70.             'cardAliases' => $cardAliases,
  71.             'cardMaterialsMandatory' => $cardMaterialsMandatory,
  72.             'cardMaterialsNotMandatory' => $cardMaterialsNotMandatory,
  73.             'cardDistributionMethods' => $cardDistributionMethods
  74.         );
  75.     }
  76.     /**
  77.      * This component is the "Top reviews" block displayed in the table of contents of reviews.
  78.      *
  79.      * @param string $console
  80.      * @param string $subsection
  81.      * @return array
  82.      * @Template("@GhFront/sidebar/top_reviews.html.twig")
  83.      */
  84.     public function topReviewsAction(string $consolestring $subsection): array {
  85.         $em $this->getDoctrine()->getManager();
  86.         $reviewsList $em->getRepository('GhDatabaseBundle:GhReview')->getListTopReviewsTableContents(
  87.             $console
  88.             $subsection,
  89.             $this->container->getParameter('table_contents_top_date_limit'),
  90.             $this->container->getParameter('table_contents_top_limit')
  91.         );
  92.         
  93.         return array('reviewsList' => $reviewsList);
  94.     }
  95.     /**
  96.      * This sidebar is the list of latest news displayed on homepage.
  97.      *
  98.      * @param ArrayCollection|GhNews[] $newsList
  99.      * @return array
  100.      * @Template()
  101.      */
  102.     public function newsAction($newsList): array {
  103.         return array('newsList' => $newsList);
  104.     }
  105.     /**
  106.      * This sidebar is the list of latest reviews displayed on homepage.
  107.      * 
  108.      * @param ArrayCollection|GhReview[] $latestReviews
  109.      * @param string $console
  110.      * @return array
  111.      * @Template() 
  112.      */
  113.     public function reviewsAction($latestReviewsstring $console): array {
  114.         return array('latestReviews' => $latestReviews'console' => $console);
  115.     }
  116.     /**
  117.      * This sidebar displays information about an author.
  118.      *
  119.      * @param GhTeam $member
  120.      * @return array
  121.      * @Template()
  122.      */
  123.     public function authorAction(?GhTeam $member): array {
  124.         return array('member' => $member);
  125.     }
  126.     /**
  127.      * This sidebar displays previous news.
  128.      *
  129.      * @param GhNews[] $news
  130.      * @return array
  131.      * @Template("@GhFront/sidebar/news_previous.html.twig")
  132.      */
  133.     public function newsPreviousAction($news): array {
  134.         return array('news' => $news);
  135.     }
  136.     /**
  137.      * This sidebar displays buy links.
  138.      *
  139.      * @param GhCard $card
  140.      * @param string[] $shopLinks
  141.      * @return array
  142.      * @Template()
  143.      */
  144.     public function buyAction($card$shopLinks): array {
  145.         return array('card' => $card'shopLinks' => $shopLinks);
  146.     }
  147.     /**
  148.      * This sidebar displays latest dossiers.
  149.      *
  150.      * @param GhDossier[] $latestDossiers
  151.      * @return array
  152.      * @Template("@GhFront/sidebar/dossiers_latest.html.twig")
  153.      */
  154.     public function dossiersLatestAction($latestDossiers): array {
  155.         return array('latestDossiers' => $latestDossiers);
  156.     }
  157. }