<?php
namespace App\Controller\Frontend;
use App\Entity\RoleType;
use App\Entity\Talent;
use App\Entity\TalentImage;
use App\Entity\TalentRole;
use App\Entity\TalentSliderImages;
use App\Entity\TalentSliderImagesBrand;
use App\Entity\TalentSliderImagesDirector;
use App\Entity\TalentSliderImagesProductionCompany;
use App\Entity\TalentVideo;
use App\Entity\TalentVideoBrand;
use App\Entity\TalentVideoDirector;
use App\Entity\TalentVideoProductionCompany;
use App\Services\Helper;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Form\Extension\Core\Type\FileType;
class TalentController extends AbstractController
{
/**
* @Route("/{_locale}/talent/list/{type}/{newTalent}", defaults={"newTalent":0})
*/
public function talentListsShowAction(Request $request, Helper $helper)
{
$em = $this->getDoctrine()->getManager();
$talentSlug = $helper->sanitize($request->get('type'));
$newTalent = $helper->sanitize($request->get('newTalent'));
if (in_array($newTalent, ["new-talent", "1"])) $newTalent = 1;
else $newTalent = 0;
$talentRole = $em->getRepository(TalentRole::class)->findOneBy(['talentSlug' => $talentSlug]);
$talents = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRole, 'deleted' => 0, 'isPublic' => 1, 'newTalent' => $newTalent], ['name' => 'ASC']);
$talentMedia = [];
foreach ($talents as $key => $value) {
$idTalent = $value->getIdTalent();
$image = $em->getRepository(TalentVideo::class)->findOneBy(['idTalent' => $idTalent, 'deleted' => 0]);
$talentMedia[$idTalent] = $image;
}
$talentRoles = $em->getRepository(TalentRole::class)->findBy([], ['orderTalentRole' => 'ASC']);
$tempArray = [];
foreach ($talentRoles as $key => $talentRoleMenu) {
$tempArray[$key]['role'] = $talentRoleMenu;
$tempArray[$key]['talent'] = false;
$talentsRoleMenu = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu, 'newTalent' => 1]);
if ($talentsRoleMenu || $talentRoleMenu->getName() == 'ROLE_PRODUCTION_DESSIGN') {
$tempArray[$key]['talent'] = true;
}
}
$talentRoles = $tempArray;
return $this->render('frontend/talent/list.html.twig', [
'talents' => $talents,
'talentRole' => $talentRole,
'talentMedia' => $talentMedia,
'talentRoles' => $talentRoles
]);
}
/**
* @Route("/{_locale}/talent/mobile/list/{newTalent}", defaults={"newTalent":0})
*/
public function talentListsMobileShowAction(Request $request, Helper $helper)
{
$em = $this->getDoctrine()->getManager();
if (!$request->getSession()->get('mobile')) {
return $this->redirectToRoute('homepage');
}
$newTalent = $helper->sanitize($request->get('newTalent'));
if (in_array($newTalent, ["new-talent", "1"])) $newTalent = 1;
else $newTalent = 0;
$roleTypePage = $em->getRepository(RoleType::class)->findOneBy(['idRoleType' => 1]);
$roles = $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage, 'deleted' => 0], ['orderTalentRole' => 'ASC']);
$talents = $em->getRepository(Talent::class)->findBy(['isHive' => 0, 'deleted' => 0, 'isPublic' => 1], ['name' => 'ASC']);
$talentMedia = [];
foreach ($talents as $key => $value) {
$idTalent = $value->getIdTalent();
$image = $em->getRepository(TalentVideo::class)->findOneBy(['idTalent' => $idTalent, 'deleted' => 0]);
$talentMedia[$idTalent] = $image;
}
$talentRoles = $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage, 'deleted' => 0], ['orderTalentRole' => 'ASC']);
$tempRolesArray = [];
foreach ($roles as $key => $role) {
$tempRolesArray[$key]['role'] = $role;
$tempRolesArray[$key]['talent'] = false;
$talentsRolesMenu = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $role]);
if ($talentsRolesMenu) {
$tempRolesArray[$key]['talent'] = true;
}
}
$roles = $tempRolesArray;
$talentRoles = $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage, 'deleted' => 0], ['orderTalentRole' => 'ASC']);
$tempArray = [];
foreach ($talentRoles as $key => $talentRoleMenu) {
$tempArray[$key]['role'] = $talentRoleMenu;
$tempArray[$key]['talent'] = false;
$talentsRoleMenu = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu, 'newTalent' => 1]);
if ($talentsRoleMenu || $talentRoleMenu->getName() == 'ROLE_PRODUCTION_DESSIGN') {
$tempArray[$key]['talent'] = true;
}
}
$talentRoles = $tempArray;
$newTalents = false;
if ($newTalent) {
$newTalents = true;
}
return $this->render('frontend/talent/list_mobile.html.twig', array(
'talents' => $talents,
'roles' => $roles,
'talentMedia' => $talentMedia,
'talentRoles' => $talentRoles,
'newTalents' => $newTalents
));
}
/**
* @Route("/{_locale}/talent/{slug}")
* @Route("/{_locale}/emerging-talent/{slug}")
*/
public function talentShow(Request $request, Helper $helper)
{
$em = $this->getDoctrine()->getManager();
$slug = $helper->sanitize($request->get('slug'));
$talent = $em->getRepository(Talent::class)->findOneBy(['slug' => $slug, 'deleted' => 0, 'isPublic' => 1]);
$idTalentRole = $talent->getIdTalent();
$talentMedia = [];
$images = $em->getRepository(TalentSliderImages::class)->findBy(['idTalent' => $talent, 'deleted' => 0]);
$videos = $em->getRepository(TalentVideo::class)->findBy(['idTalent' => $talent, 'deleted' => 0]);
foreach ($images as $keyI => $valueI) {
if (!$valueI->getDeleted()) {
$imagesSliders = $em->getRepository(TalentImage::class)->findBy(['idSlider' => $valueI->getIdSlider(), 'deleted' => 0], ['orderImage' => 'ASC']);
$brands = $em->getRepository(TalentSliderImagesBrand::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
$directors = $em->getRepository(TalentSliderImagesDirector::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
$prodCompanies = $em->getRepository(TalentSliderImagesProductionCompany::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
$talentMedia[($valueI->getOrderSlider() - 1)]['slider'] = $valueI;
$talentMedia[($valueI->getOrderSlider() - 1)]['images'] = $imagesSliders;
$talentMedia[($valueI->getOrderSlider() - 1)]['brands'] = $brands;
$talentMedia[($valueI->getOrderSlider() - 1)]['directors'] = $directors;
$talentMedia[($valueI->getOrderSlider() - 1)]['prodCompanies'] = $prodCompanies;
}
}
foreach ($videos as $keyV => $valueV) {
if (!$valueV->getDeleted()) {
$brands = $em->getRepository(TalentVideoBrand::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
$directors = $em->getRepository(TalentVideoDirector::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
$prodCompanies = $em->getRepository(TalentVideoProductionCompany::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
$talentMedia[($valueV->getOrderVideo() - 1)]['video'] = $valueV;
$talentMedia[($valueV->getOrderVideo() - 1)]['brands'] = $brands;
$talentMedia[($valueV->getOrderVideo() - 1)]['directors'] = $directors;
$talentMedia[($valueV->getOrderVideo() - 1)]['prodCompanies'] = $prodCompanies;
}
ksort($talentMedia, 1);
}
$talentRoles = $em->getRepository(TalentRole::class)->findBy([],['orderTalentRole' => 'ASC']);
$tempArray = [];
foreach ($talentRoles as $key => $talentRole) {
$tempArray[$key]['role'] = $talentRole;
$tempArray[$key]['talent'] = false;
$talents = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRole, 'newTalent' => 1]);
if ($talents || $talentRole->getName() == 'ROLE_PRODUCTION_DESSIGN') {
$tempArray[$key]['talent'] = true;
}
}
$talentRoles = $tempArray;
return $this->render('frontend/talent/index.html.twig', [
'talent' => $talent,
'talentMedia' => $talentMedia,
'talentRoles' => $talentRoles
]);
}
// HIVE VIEWS AND LIST
/**
* @Route("/{_locale}/network/list")
*/
public function networkListAction(Request $request, Helper $helper)
{
$em = $this->getDoctrine()->getManager();
$roleTypePortfolio = $em->getRepository(RoleType::class)->findOneBy(['idRoleType' => 1], []);
$talentRole = $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePortfolio], ['orderTalentRole' => 'ASC']);
$talents = $em->getRepository(Talent::class)->findBy(['isHive' => 1, 'deleted' => 0, 'isPublic' => 1], ['name' => 'ASC']);
$talentMedia = [];
foreach ($talents as $key => $value) {
$idTalent = $value->getIdTalent();
$image = $em->getRepository(TalentVideo::class)->findOneBy(['idTalent' => $idTalent, 'deleted' => 0]);
$talentMedia[$idTalent] = $image;
}
$talentRoles = $em->getRepository(TalentRole::class)->findBy([], ['orderTalentRole' => 'ASC']);
$tempArray = [];
foreach ($talentRoles as $key => $talentRoleMenu) {
$tempArray[$key]['role'] = $talentRoleMenu;
$tempArray[$key]['talent'] = false;
$talentsRoleMenu = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu, 'newTalent' => 1]);
if ($talentsRoleMenu || $talentRoleMenu->getName() == 'ROLE_PRODUCTION_DESSIGN') {
$tempArray[$key]['talent'] = true;
}
}
$talentRoles = $tempArray;
return $this->render('frontend/hive/list.html.twig', [
'talents' => $talents,
'talentRole' => $talentRole,
'talentMedia' => $talentMedia,
'talentRoles' => $talentRoles
]);
}
/**
* @Route("/{_locale}/network/mobile/list")
*/
public function networkListsMobileShowAction(Request $request, Helper $helper)
{
$em = $this->getDoctrine()->getManager();
if (!$request->getSession()->get('mobile')) {
return $this->redirectToRoute('homepage');
}
$roleTypePage = $em->getRepository(RoleType::class)->findOneBy(['idRoleType' => 1]);
$roles = $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage, 'deleted' => 0], ['orderTalentRole' => 'ASC']);
$talents = $em->getRepository(Talent::class)->findBy(['deleted' => 0, 'isPublic' => 1, 'isHive' => 1], ['name' => 'ASC']);
$talentMedia = [];
foreach ($talents as $key => $value) {
$idTalent = $value->getIdTalent();
$image = $em->getRepository(TalentVideo::class)->findOneBy(['idTalent' => $idTalent, 'deleted' => 0]);
$talentMedia[$idTalent] = $image;
}
$talentRoles = $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage, 'deleted' => 0], ['orderTalentRole' => 'ASC']);
$tempRolesArray = [];
foreach ($roles as $key => $role) {
$tempRolesArray[$key]['role'] = $role;
$tempRolesArray[$key]['talent'] = false;
$talentsRolesMenu = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $role, 'isHive' => 1, 'deleted' => 0]);
if ($talentsRolesMenu) {
$tempRolesArray[$key]['talent'] = true;
}
}
$roles = $tempRolesArray;
$talentRoles = $em->getRepository(TalentRole::class)->findBy(['roleType' => $roleTypePage, 'deleted' => 0], ['orderTalentRole' => 'ASC']);
$tempArray = [];
foreach ($talentRoles as $key => $talentRoleMenu) {
$tempArray[$key]['role'] = $talentRoleMenu;
$tempArray[$key]['talent'] = false;
$talentsRoleMenu = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu, 'isHive' => 1, 'deleted' => 0]);
if ($talentsRoleMenu) {
$tempArray[$key]['talent'] = true;
}
}
$talentRoles = $tempArray;
return $this->render('frontend/hive/list_mobile.html.twig', array(
'talents' => $talents,
'roles' => $roles,
'talentMedia' => $talentMedia,
'talentRoles' => $talentRoles,
));
}
/**
* @Route("/{_locale}/hive/{slug}")
*/
public function hiveShow(Request $request, Helper $helper)
{
$em = $this->getDoctrine()->getManager();
$slug = $helper->sanitize($request->get('slug'));
$talent = $em->getRepository(Talent::class)->findOneBy(['slug' => $slug, 'isHive' => 1, 'deleted' => 0, 'isPublic' => 1]);
$idTalentRole = $talent->getIdTalent();
$talentMedia = [];
$images = $em->getRepository(TalentSliderImages::class)->findBy(['idTalent' => $talent, 'deleted' => 0]);
$videos = $em->getRepository(TalentVideo::class)->findBy(['idTalent' => $talent, 'deleted' => 0]);
foreach ($images as $keyI => $valueI) {
if (!$valueI->getDeleted()) {
$imagesSliders = $em->getRepository(TalentImage::class)->findBy(['idSlider' => $valueI->getIdSlider(), 'deleted' => 0], ['orderImage' => 'ASC']);
$brands = $em->getRepository(TalentSliderImagesBrand::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
$directors = $em->getRepository(TalentSliderImagesDirector::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
$prodCompanies = $em->getRepository(TalentSliderImagesProductionCompany::class)->findBy(['idSlider' => $valueI->getIdSlider()]);
$talentMedia[($valueI->getOrderSlider() - 1)]['slider'] = $valueI;
$talentMedia[($valueI->getOrderSlider() - 1)]['images'] = $imagesSliders;
$talentMedia[($valueI->getOrderSlider() - 1)]['brands'] = $brands;
$talentMedia[($valueI->getOrderSlider() - 1)]['directors'] = $directors;
$talentMedia[($valueI->getOrderSlider() - 1)]['prodCompanies'] = $prodCompanies;
}
}
foreach ($videos as $keyV => $valueV) {
if (!$valueV->getDeleted()) {
$brands = $em->getRepository(TalentVideoBrand::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
$directors = $em->getRepository(TalentVideoDirector::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
$prodCompanies = $em->getRepository(TalentVideoProductionCompany::class)->findBy(['idTalentVideo' => $valueV->getIdTalentVideo()]);
$talentMedia[($valueV->getOrderVideo() - 1)]['video'] = $valueV;
$talentMedia[($valueV->getOrderVideo() - 1)]['brands'] = $brands;
$talentMedia[($valueV->getOrderVideo() - 1)]['directors'] = $directors;
$talentMedia[($valueV->getOrderVideo() - 1)]['prodCompanies'] = $prodCompanies;
}
ksort($talentMedia, 1);
}
$talentRoles = $em->getRepository(TalentRole::class)->findAll();
$tempArray = [];
foreach ($talentRoles as $key => $talentRole) {
$tempArray[$key]['role'] = $talentRole;
$tempArray[$key]['talent'] = false;
$talents = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRole, 'newTalent' => 1]);
if ($talents || $talentRole->getName() == 'ROLE_PRODUCTION_DESSIGN') {
$tempArray[$key]['talent'] = true;
}
}
$talentRoles = $tempArray;
return $this->render('frontend/hive/index.html.twig', [
'talent' => $talent,
'talentMedia' => $talentMedia,
'talentRoles' => $talentRoles
]);
}
/**
* @Route("/{_locale}/emerging-talent")
*/
public function emergingTalent()
{
$em = $this->getDoctrine()->getManager();
$talentRoles = $em->getRepository(TalentRole::class)->findBy(['visible' => 1 , 'deleted' => 0], ['orderTalentRole' => 'ASC']);
$tempArray = [];
foreach ($talentRoles as $key => $talentRoleMenu) {
$tempArray[$key]['role'] = $talentRoleMenu;
$tempArray[$key]['talent'] = false;
$talentsRoleMenu = $em->getRepository(Talent::class)->findBy(['idTalentRole' => $talentRoleMenu, 'deleted' => 0]);
if ($talentsRoleMenu) {
$tempArray[$key]['talent'] = true;
}
}
$talentRoles = $tempArray;
$artRole = $em->getRepository(TalentRole::class)->findOneBy(['talentSlug' => 'productions-designers']);
$styleRole = $em->getRepository(TalentRole::class)->findOneBy(['talentSlug' => 'costume-designers']);
$artists = $em->getRepository(Talent::class)->findBy(['newTalent' => true, 'isPublic' => true, 'idTalentRole' => $artRole]);
$stylist = $em->getRepository(Talent::class)->findBy(['newTalent' => true, 'isPublic' => true, 'idTalentRole' => $styleRole]);
return $this->render('frontend/talent/emerging/list.html.twig', [
'artists' => $artists,
'stylists' => $stylist,
'talentRoles' => $talentRoles
]);
}
}