src/Controller/Frontend/TalentController.php line 170

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Frontend;
  3. use App\Entity\RoleType;
  4. use App\Entity\Talent;
  5. use App\Entity\TalentImage;
  6. use App\Entity\TalentRole;
  7. use App\Entity\TalentSliderImages;
  8. use App\Entity\TalentSliderImagesBrand;
  9. use App\Entity\TalentSliderImagesDirector;
  10. use App\Entity\TalentSliderImagesProductionCompany;
  11. use App\Entity\TalentVideo;
  12. use App\Entity\TalentVideoBrand;
  13. use App\Entity\TalentVideoDirector;
  14. use App\Entity\TalentVideoProductionCompany;
  15. use App\Services\Helper;
  16. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\Response;
  19. use Symfony\Component\Routing\Annotation\Route;
  20. use Symfony\Component\Validator\Constraints\File;
  21. use Symfony\Component\Form\Extension\Core\Type\FileType;
  22. class TalentController extends AbstractController
  23. {
  24.     /**
  25.      * @Route("/{_locale}/talent/list/{type}/{newTalent}", defaults={"newTalent":0})
  26.      */
  27.     public function talentListsShowAction(Request $requestHelper $helper)
  28.     {
  29.         $em $this->getDoctrine()->getManager();
  30.         $talentSlug $helper->sanitize($request->get('type'));
  31.         $newTalent $helper->sanitize($request->get('newTalent'));
  32.         if (in_array($newTalent, ["new-talent""1"])) $newTalent 1;
  33.         else $newTalent 0;
  34.         $talentRole $em->getRepository(TalentRole::class)->findOneBy(['talentSlug' => $talentSlug]);
  35.         $talents $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRole'deleted' => 0'isPublic' => 1'newTalent' => $newTalent], ['name' => 'ASC']);
  36.         $talentMedia = [];
  37.         foreach ($talents as $key => $value) {
  38.             $idTalent $value->getIdTalent();
  39.             $image $em->getRepository(TalentVideo::class)->findOneBy(['idTalent' => $idTalent'deleted' => 0]);
  40.             $talentMedia[$idTalent] = $image;
  41.         }
  42.         $talentRoles $em->getRepository(TalentRole::class)->findBy([], ['orderTalentRole' => 'ASC']);
  43.         $tempArray = [];
  44.         foreach ($talentRoles as $key => $talentRoleMenu) {
  45.             $tempArray[$key]['role'] = $talentRoleMenu;
  46.             $tempArray[$key]['talent'] = false;
  47.             $talentsRoleMenu $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu'newTalent' => 1]);
  48.             if ($talentsRoleMenu || $talentRoleMenu->getName() == 'ROLE_PRODUCTION_DESSIGN') {
  49.                 $tempArray[$key]['talent'] = true;
  50.             }
  51.         }
  52.         $talentRoles $tempArray;
  53.         return $this->render('frontend/talent/list.html.twig', [
  54.             'talents' => $talents,
  55.             'talentRole' => $talentRole,
  56.             'talentMedia' => $talentMedia,
  57.             'talentRoles' => $talentRoles
  58.         ]);
  59.     }
  60.     /**
  61.      * @Route("/{_locale}/talent/mobile/list/{newTalent}", defaults={"newTalent":0})
  62.      */
  63.     public function talentListsMobileShowAction(Request $requestHelper $helper)
  64.     {
  65.         $em $this->getDoctrine()->getManager();
  66.         if (!$request->getSession()->get('mobile')) {
  67.             return $this->redirectToRoute('homepage');
  68.         }
  69.         $newTalent $helper->sanitize($request->get('newTalent'));
  70.         if (in_array($newTalent, ["new-talent""1"])) $newTalent 1;
  71.         else $newTalent 0;
  72.         $roleTypePage $em->getRepository(RoleType::class)->findOneBy(['idRoleType' => 1]);
  73.         $roles $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage'deleted' => 0], ['orderTalentRole' => 'ASC']);
  74.         $talents $em->getRepository(Talent::class)->findBy(['isHive' => 0'deleted' => 0'isPublic' => 1], ['name' => 'ASC']);
  75.         $talentMedia = [];
  76.         foreach ($talents as $key => $value) {
  77.             $idTalent $value->getIdTalent();
  78.             $image $em->getRepository(TalentVideo::class)->findOneBy(['idTalent' => $idTalent'deleted' => 0]);
  79.             $talentMedia[$idTalent] = $image;
  80.         }
  81.         $talentRoles $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage'deleted' => 0], ['orderTalentRole' => 'ASC']);
  82.         $tempRolesArray = [];
  83.         foreach ($roles as $key => $role) {
  84.             $tempRolesArray[$key]['role'] = $role;
  85.             $tempRolesArray[$key]['talent'] = false;
  86.             $talentsRolesMenu $em->getRepository(Talent::class)->findBy(['idTalentRole' => $role]);
  87.             if ($talentsRolesMenu) {
  88.                 $tempRolesArray[$key]['talent'] = true;
  89.             }
  90.         }
  91.         $roles $tempRolesArray;
  92.         $talentRoles $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage'deleted' => 0], ['orderTalentRole' => 'ASC']);
  93.         $tempArray = [];
  94.         foreach ($talentRoles as $key => $talentRoleMenu) {
  95.             $tempArray[$key]['role'] = $talentRoleMenu;
  96.             $tempArray[$key]['talent'] = false;
  97.             $talentsRoleMenu $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu'newTalent' => 1]);
  98.             if ($talentsRoleMenu || $talentRoleMenu->getName() == 'ROLE_PRODUCTION_DESSIGN') {
  99.                 $tempArray[$key]['talent'] = true;
  100.             }
  101.         }
  102.         $talentRoles $tempArray;
  103.         $newTalents false;
  104.         if ($newTalent) {
  105.             $newTalents true;
  106.         }
  107.         return $this->render('frontend/talent/list_mobile.html.twig', array(
  108.             'talents' => $talents,
  109.             'roles' => $roles,
  110.             'talentMedia' => $talentMedia,
  111.             'talentRoles' => $talentRoles,
  112.             'newTalents' => $newTalents
  113.         ));
  114.     }
  115.     /**
  116.      * @Route("/{_locale}/talent/{slug}")
  117.      * @Route("/{_locale}/emerging-talent/{slug}")
  118.      */
  119.     public function talentShow(Request $requestHelper $helper)
  120.     {
  121.         $em $this->getDoctrine()->getManager();
  122.         $slug $helper->sanitize($request->get('slug'));
  123.         $talent $em->getRepository(Talent::class)->findOneBy(['slug' => $slug'deleted' => 0'isPublic' => 1]);
  124.         $idTalentRole $talent->getIdTalent();
  125.         $talentMedia = [];
  126.         $images $em->getRepository(TalentSliderImages::class)->findBy(['idTalent' => $talent'deleted' => 0]);
  127.         $videos $em->getRepository(TalentVideo::class)->findBy(['idTalent' => $talent'deleted' => 0]);
  128.         foreach ($images as $keyI => $valueI) {
  129.             if (!$valueI->getDeleted()) {
  130.                 $imagesSliders $em->getRepository(TalentImage::class)->findBy(['idSlider' => $valueI->getIdSlider(), 'deleted' => 0], ['orderImage' => 'ASC']);
  131.                 $brands $em->getRepository(TalentSliderImagesBrand::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
  132.                 $directors $em->getRepository(TalentSliderImagesDirector::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
  133.                 $prodCompanies $em->getRepository(TalentSliderImagesProductionCompany::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
  134.                 $talentMedia[($valueI->getOrderSlider() - 1)]['slider'] = $valueI;
  135.                 $talentMedia[($valueI->getOrderSlider() - 1)]['images'] = $imagesSliders;
  136.                 $talentMedia[($valueI->getOrderSlider() - 1)]['brands'] = $brands;
  137.                 $talentMedia[($valueI->getOrderSlider() - 1)]['directors'] = $directors;
  138.                 $talentMedia[($valueI->getOrderSlider() - 1)]['prodCompanies'] = $prodCompanies;
  139.             }
  140.         }
  141.         foreach ($videos as $keyV => $valueV) {
  142.             if (!$valueV->getDeleted()) {
  143.                 $brands $em->getRepository(TalentVideoBrand::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
  144.                 $directors $em->getRepository(TalentVideoDirector::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
  145.                 $prodCompanies $em->getRepository(TalentVideoProductionCompany::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
  146.                 $talentMedia[($valueV->getOrderVideo() - 1)]['video'] = $valueV;
  147.                 $talentMedia[($valueV->getOrderVideo() - 1)]['brands'] = $brands;
  148.                 $talentMedia[($valueV->getOrderVideo() - 1)]['directors'] = $directors;
  149.                 $talentMedia[($valueV->getOrderVideo() - 1)]['prodCompanies'] = $prodCompanies;
  150.             }
  151.             ksort($talentMedia1);
  152.         }
  153.         $talentRoles $em->getRepository(TalentRole::class)->findBy([],['orderTalentRole' => 'ASC']);
  154.         $tempArray = [];
  155.         foreach ($talentRoles as $key => $talentRole) {
  156.             $tempArray[$key]['role'] = $talentRole;
  157.             $tempArray[$key]['talent'] = false;
  158.             $talents $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRole'newTalent' => 1]);
  159.             if ($talents || $talentRole->getName() == 'ROLE_PRODUCTION_DESSIGN') {
  160.                 $tempArray[$key]['talent'] = true;
  161.             }
  162.         }
  163.         $talentRoles $tempArray;
  164.         return $this->render('frontend/talent/index.html.twig', [
  165.             'talent' => $talent,
  166.             'talentMedia' => $talentMedia,
  167.             'talentRoles' => $talentRoles
  168.         ]);
  169.     }
  170.     // HIVE VIEWS AND LIST
  171.     /**
  172.      * @Route("/{_locale}/network/list")
  173.      */
  174.     public function networkListAction(Request $requestHelper $helper)
  175.     {
  176.         $em $this->getDoctrine()->getManager();
  177.         $roleTypePortfolio $em->getRepository(RoleType::class)->findOneBy(['idRoleType' => 1], []);
  178.         $talentRole $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePortfolio], ['orderTalentRole' => 'ASC']);
  179.         $talents $em->getRepository(Talent::class)->findBy(['isHive' => 1'deleted' => 0'isPublic' => 1], ['name' => 'ASC']);
  180.         $talentMedia = [];
  181.         foreach ($talents as $key => $value) {
  182.             $idTalent $value->getIdTalent();
  183.             $image $em->getRepository(TalentVideo::class)->findOneBy(['idTalent' => $idTalent'deleted' => 0]);
  184.             $talentMedia[$idTalent] = $image;
  185.         }
  186.         $talentRoles $em->getRepository(TalentRole::class)->findBy([], ['orderTalentRole' => 'ASC']);
  187.         $tempArray = [];
  188.         foreach ($talentRoles as $key => $talentRoleMenu) {
  189.             $tempArray[$key]['role'] = $talentRoleMenu;
  190.             $tempArray[$key]['talent'] = false;
  191.             $talentsRoleMenu $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu'newTalent' => 1]);
  192.             if ($talentsRoleMenu || $talentRoleMenu->getName() == 'ROLE_PRODUCTION_DESSIGN') {
  193.                 $tempArray[$key]['talent'] = true;
  194.             }
  195.         }
  196.         $talentRoles $tempArray;
  197.         return $this->render('frontend/hive/list.html.twig', [
  198.             'talents' => $talents,
  199.             'talentRole' => $talentRole,
  200.             'talentMedia' => $talentMedia,
  201.             'talentRoles' => $talentRoles
  202.         ]);
  203.     }
  204.     /**
  205.      * @Route("/{_locale}/network/mobile/list")
  206.      */
  207.     public function networkListsMobileShowAction(Request $requestHelper $helper)
  208.     {
  209.         $em $this->getDoctrine()->getManager();
  210.         if (!$request->getSession()->get('mobile')) {
  211.             return $this->redirectToRoute('homepage');
  212.         }
  213.         $roleTypePage $em->getRepository(RoleType::class)->findOneBy(['idRoleType' => 1]);
  214.         $roles $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage'deleted' => 0], ['orderTalentRole' => 'ASC']);
  215.         $talents $em->getRepository(Talent::class)->findBy(['deleted' => 0'isPublic' => 1'isHive' => 1], ['name' => 'ASC']);
  216.         $talentMedia = [];
  217.         foreach ($talents as $key => $value) {
  218.             $idTalent $value->getIdTalent();
  219.             $image $em->getRepository(TalentVideo::class)->findOneBy(['idTalent' => $idTalent'deleted' => 0]);
  220.             $talentMedia[$idTalent] = $image;
  221.         }
  222.         $talentRoles $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage'deleted' => 0], ['orderTalentRole' => 'ASC']);
  223.         $tempRolesArray = [];
  224.         foreach ($roles as $key => $role) {
  225.             $tempRolesArray[$key]['role'] = $role;
  226.             $tempRolesArray[$key]['talent'] = false;
  227.             $talentsRolesMenu $em->getRepository(Talent::class)->findBy(['idTalentRole' => $role'isHive' => 1'deleted' => 0]);
  228.             if ($talentsRolesMenu) {
  229.                 $tempRolesArray[$key]['talent'] = true;
  230.             }
  231.         }
  232.         $roles $tempRolesArray;
  233.         $talentRoles $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage'deleted' => 0], ['orderTalentRole' => 'ASC']);
  234.         $tempArray = [];
  235.         foreach ($talentRoles as $key => $talentRoleMenu) {
  236.             $tempArray[$key]['role'] = $talentRoleMenu;
  237.             $tempArray[$key]['talent'] = false;
  238.             $talentsRoleMenu $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu'isHive' => 1'deleted' => 0]);
  239.             if ($talentsRoleMenu) {
  240.                 $tempArray[$key]['talent'] = true;
  241.             }
  242.         }
  243.         $talentRoles $tempArray;
  244.         return $this->render('frontend/hive/list_mobile.html.twig', array(
  245.             'talents' => $talents,
  246.             'roles' => $roles,
  247.             'talentMedia' => $talentMedia,
  248.             'talentRoles' => $talentRoles,
  249.         ));
  250.     }
  251.     /**
  252.      * @Route("/{_locale}/hive/{slug}")
  253.      */
  254.     public function hiveShow(Request $requestHelper $helper)
  255.     {
  256.         $em $this->getDoctrine()->getManager();
  257.         $slug $helper->sanitize($request->get('slug'));
  258.         $talent $em->getRepository(Talent::class)->findOneBy(['slug' => $slug'isHive' => 1'deleted' => 0'isPublic' => 1]);
  259.         $idTalentRole $talent->getIdTalent();
  260.         $talentMedia = [];
  261.         $images $em->getRepository(TalentSliderImages::class)->findBy(['idTalent' => $talent'deleted' => 0]);
  262.         $videos $em->getRepository(TalentVideo::class)->findBy(['idTalent' => $talent'deleted' => 0]);
  263.         foreach ($images as $keyI => $valueI) {
  264.             if (!$valueI->getDeleted()) {
  265.                 $imagesSliders $em->getRepository(TalentImage::class)->findBy(['idSlider' => $valueI->getIdSlider(), 'deleted' => 0], ['orderImage' => 'ASC']);
  266.                 $brands $em->getRepository(TalentSliderImagesBrand::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
  267.                 $directors $em->getRepository(TalentSliderImagesDirector::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
  268.                 $prodCompanies $em->getRepository(TalentSliderImagesProductionCompany::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
  269.                 $talentMedia[($valueI->getOrderSlider() - 1)]['slider'] = $valueI;
  270.                 $talentMedia[($valueI->getOrderSlider() - 1)]['images'] = $imagesSliders;
  271.                 $talentMedia[($valueI->getOrderSlider() - 1)]['brands'] = $brands;
  272.                 $talentMedia[($valueI->getOrderSlider() - 1)]['directors'] = $directors;
  273.                 $talentMedia[($valueI->getOrderSlider() - 1)]['prodCompanies'] = $prodCompanies;
  274.             }
  275.         }
  276.         foreach ($videos as $keyV => $valueV) {
  277.             if (!$valueV->getDeleted()) {
  278.                 $brands $em->getRepository(TalentVideoBrand::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
  279.                 $directors $em->getRepository(TalentVideoDirector::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
  280.                 $prodCompanies $em->getRepository(TalentVideoProductionCompany::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
  281.                 $talentMedia[($valueV->getOrderVideo() - 1)]['video'] = $valueV;
  282.                 $talentMedia[($valueV->getOrderVideo() - 1)]['brands'] = $brands;
  283.                 $talentMedia[($valueV->getOrderVideo() - 1)]['directors'] = $directors;
  284.                 $talentMedia[($valueV->getOrderVideo() - 1)]['prodCompanies'] = $prodCompanies;
  285.             }
  286.             ksort($talentMedia1);
  287.         }
  288.         $talentRoles $em->getRepository(TalentRole::class)->findAll();
  289.         $tempArray = [];
  290.         foreach ($talentRoles as $key => $talentRole) {
  291.             $tempArray[$key]['role'] = $talentRole;
  292.             $tempArray[$key]['talent'] = false;
  293.             $talents $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRole'newTalent' => 1]);
  294.             if ($talents || $talentRole->getName() == 'ROLE_PRODUCTION_DESSIGN') {
  295.                 $tempArray[$key]['talent'] = true;
  296.             }
  297.         }
  298.         $talentRoles $tempArray;
  299.         return $this->render('frontend/hive/index.html.twig', [
  300.             'talent' => $talent,
  301.             'talentMedia' => $talentMedia,
  302.             'talentRoles' => $talentRoles
  303.         ]);
  304.     }
  305.     /**
  306.      * @Route("/{_locale}/emerging-talent")
  307.      */
  308.     public function emergingTalent()
  309.     {
  310.         $em $this->getDoctrine()->getManager();
  311.         $talentRoles $em->getRepository(TalentRole::class)->findBy(['visible' => 'deleted' => 0], ['orderTalentRole' => 'ASC']);
  312.         $tempArray = [];
  313.         foreach ($talentRoles as $key => $talentRoleMenu) {
  314.             $tempArray[$key]['role'] = $talentRoleMenu;
  315.             $tempArray[$key]['talent'] = false;
  316.             $talentsRoleMenu $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu'deleted' => 0]);
  317.             if ($talentsRoleMenu) {
  318.                 $tempArray[$key]['talent'] = true;
  319.             }
  320.         }
  321.         $talentRoles $tempArray;
  322.         $artRole $em->getRepository(TalentRole::class)->findOneBy(['talentSlug' => 'productions-designers']);
  323.         $styleRole $em->getRepository(TalentRole::class)->findOneBy(['talentSlug' => 'costume-designers']);
  324.         $artists $em->getRepository(Talent::class)->findBy(['newTalent' => true'isPublic' => true'idTalentRole' => $artRole]);
  325.         $stylist $em->getRepository(Talent::class)->findBy(['newTalent' => true'isPublic' => true'idTalentRole' => $styleRole]);
  326.         return $this->render('frontend/talent/emerging/list.html.twig', [
  327.             'artists' => $artists,
  328.             'stylists' => $stylist,
  329.             'talentRoles' => $talentRoles
  330.         ]);
  331.     }
  332. }