^ null
^ null
^ null
^ null
Symfony Profiler
<?php
namespace App\Controller;
use App\Entity\Entraineur;
use App\Entity\Rencontre;
use App\Form\EntraineurType;
use App\Form\InstallationType;
use App\Repository\RencontreRepository;
use App\Service\FileUploader;
use DateTime;
use DateTimeZone;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class FrontController extends AbstractController
{
/**
* @Route("/", name="index")
*/
public function index()
{
///////////////////// LUNDI 06 DECEMBRE 2021, 15H51 ///////////////////////
/////// https://duckduckgo.com/?t=ffab&q=symfony+binaryfileresponse&ia=web
/////// https://symfony.com/doc/current/components/http_foundation.html#serving-files
/////// if you are serving a static file, you can use a BinaryFileResponse:
return new BinaryFileResponse($this->getParameter('kernel.project_dir') . '/public/index.html');
//return $this->redirectToRoute('connexion');
//return $this->render('index.html');
}
/**
* @Route("/EXinstallation", name="EXindex")
*/
public function installation()
{
$myForm = $this->createForm(InstallationType::class);
return $this->render('front/installation.html.twig', [
'myForm' => $myForm->createView()
]);
}
/**
* @Route("/DSSinscription", name="inscription")
* @Route("/DSSregistration", name="CDFASregistration")
*/
public function inscription(Request $request, EntityManagerInterface $manager, UserPasswordEncoderInterface $encoder, FileUploader $fileUploader)
{
$entraineur = new Entraineur();
$myForm = $this->createForm(EntraineurType::class, $entraineur);
$myForm->handleRequest($request);
// dump($request);
// dump($request->getHost());
// dump($request->getRequestUri());
// dump($request->attributes->get('_route'));
if($myForm->isSubmitted() && $myForm->isValid())
{
$passwordCrypte = $encoder->encodePassword($entraineur, $entraineur->getPassword());
$entraineur->setPassword($passwordCrypte);
$entraineur->setRoles( ['ROLE_USER'] );
$uploadedImageFile = $myForm->get('image')->getData();
if ($uploadedImageFile)
{
$storedImageFile = $fileUploader->upload(
$uploadedImageFile,
$this->getParameter('coaches_directory')
);
$entraineur->setImage($storedImageFile->getFilename());
}
$uploadedImageFileII = $myForm->get('clubLogo')->getData();
if ($uploadedImageFileII)
{
$storedImageFile = $fileUploader->upload(
$uploadedImageFileII,
$this->getParameter('clubs_directory')
);
$entraineur->setClubLogo($storedImageFile->getFilename());
}
$manager->persist($entraineur);
$manager->flush();
//if($request->attributes->get('_route') == 'CDFASregistration')
//return $this->redirectToRoute('login');
return $this->redirectToRoute('connexion');
}
return $this->render('front/inscription.html.twig', [
'myForm' => $myForm->createView()
]);
}
/**
* @Route("/connexion", name="connexion")
*/
public function connexion(AuthenticationUtils $util, Request $request)
{
if( $request->getHost() == 'cdfas.datasports.fr')
return $this->render('front/connexionCDFAS.html.twig', [
'lastUserName' => $util->getLastUsername(),
'error' => $util->getLastAuthenticationError()
]);
return $this->render('front/connexion.html.twig', [
'lastUserName' => $util->getLastUsername(),
'error' => $util->getLastAuthenticationError()
]);
}
/**
* @Route("/deconnexion", name="deconnexion")
*/
public function deconnexion()
{
dump('test/test/test');
$this->addFlash('adios', 'A la prochaine');
//return $this->redirectToRoute('connexion');
}
/**
* @Route("/my/cron", name="trainingLoadCron")
*/
public function trainingLoadCron(RencontreRepository $rencontreRepo, Request $request, EntityManagerInterface $manager)
{
$dateHeureCurrent = new DateTime('now', new DateTimeZone('Europe/Paris'));
$dateHeureNext = new DateTime('now', new DateTimeZone('Europe/Paris'));
$dateHeureNext->modify('+90 minutes');
$comingTrainingList = $rencontreRepo->findAllComingTrainings();
dump($comingTrainingList);
/////// "https://test2.datasports.fr"
define('DNS', $request->getSchemeAndHttpHost() );
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <noreply@test.datasports.fr>' . "\r\n";
$from = 'noreply@test.datasports.fr';
$subject = 'DATASPORTS >> FORMUL\'R DE CHARGE D\'ENTRAINEMENT >> A REMPLIR !!!';
$message = '';
foreach($comingTrainingList as $oneTraining)
{
/////// "555"
$trainingID = $oneTraining->getId();
foreach( $oneTraining->getEquipe()->getJoueurList() as $oneJoueur )
{
//////// "8c8ac29a4f0cbd394ab8377ad30163d3"
$token = md5(
$oneJoueur->getEmail()
. '#Training#'
. $oneJoueur->getDateNaissance()->format('Y-m-d')
. '#Training#'
. $trainingID
);
////////////// "/my/stats/trainingLoadLogin/555/8c8ac29a4f0cbd394ab8377ad30163d3"
$urlBasic = $this->generateUrl('trainingLoadLogin', [
'myRencontreId' => $trainingID,
'myPlayerToken' => $token]
);
///////// "https://test2.datasports.fr/my/stats/trainingLoadLogin/555/8c8ac29a4f0cbd394ab8377ad30163d3"
$urlFinal = DNS . $urlBasic;
$to = $oneJoueur->getEmail();
$genre = $oneJoueur->getGenre() ? 'Mr' : 'Mme';
$nomPrenom = $oneJoueur->getNomPrenom();
$trainingDate = $oneTraining->getDate()->format('d/m/Y');
$trainingHour = $oneTraining->getHeure()->format('H:i');
$emailing = $oneTraining->getEmailing();
if( $emailing == Rencontre::NOMAILS || $emailing == null )
{
$subject = "DataSports >> Charge d'Entraînement ($trainingDate - 1/2) >> A REMPLIR !!!";
$message = "
Bonjour $genre $nomPrenom,<br>
Veuillez remplir le PREMIER formulaire de charge d'entraînement,<br>
la charge de pré-entraînement<br>
si possible AVANT l'entraînement<br>
la séance d'entraînement du $trainingDate à $trainingHour, svp :
<br><br>
<a href=\"$urlFinal\">$urlFinal</a>
<br><br>
Cordialement<br><br>
NOTE : Un second formulaire vous sera envoyé après cet entraînement,<br>
soyez donc présent et réactif pour ainsi ne pas decevoir votre chère entraîneur.
";
}
elseif( $emailing == Rencontre::PRETRAINING )
{
$subject = "DataSports >> Charge d'Entraînement ($trainingDate - Suite et Fin) >> A REMPLIR !!!";
$message = "
Bonjour $genre $nomPrenom,<br>
Veuillez remplir le DERNIER formulaire de charge d'entraînement,<br>
la charge de post-entraînement<br>
en toute logique APRES l'entraînement<br>
la séance d'entraînement du $trainingDate à $trainingHour, svp :
<br><br>
<a href=\"$urlFinal\">$urlFinal</a>
<br><br>
Cordialement
";
}
if( $to == 'jamaliss@hotmail.fr' || $to == 'mamssan@gmail.com' || $to == 'oxyprop@gmail.com' || $to == 'racine@neuf.fr' )
mail( $to, $subject, $message, $headers );
dump($urlFinal);
}
$oneTraining->emailNextStep();
$manager->persist($oneTraining);
dump($oneTraining);
}
$manager->flush();
return new Response('<!DOCTYPE html><html>'
.'<head><title>Cron Job of DSS</title></head>'
.'<body>'
.$dateHeureCurrent->format('Y-m-d H:i:s')
.'<br>'
.$dateHeureNext->format('Y-m-d H:i:s')
.'<br>'
.'<br>'
.'<br>'
. $message
.'<br>'
.'<br>'
.'</body></html>');
}
}