You are on page 1of 9

AJOUTER ACTION

public function AjoutAthleteAction(Request $request){


$athlete= new Athlete();
$form=$this->createForm(AthleteType::class,$athlete);
$form->handleRequest($request);
$em=$this->getDoctrine()->getManager();
if($form->isSubmitted()){
$em->persist($athlete);
$em->flush();
return $this->redirectToRoute('affichera');
}

return $this->render('@Athlete/Default/ajoutahlete.html.twig',array('f'=>$form-
>createView()));
}

AFFICHAGE FINDALL ACTION


public function AfficheAthelteAction(){
$athletes=$this->getDoctrine()->getRepository(Athlete::class)->findAll();
return $this-
>render('@Athlete/Default/afficheathlete.html.twig',array('athletes'=>$athletes));
}

recherche selon cin


function RechercheAction(Request $request){
$athlete=new Athlete();

$Form=$this->createFormBuilder($athlete)
->add('cin')
->add('Rechercher',SubmitType::class)
->getForm();
$Form->handleRequest($request);
if($Form->isSubmitted()){
$athlete=$this->getDoctrine()
->getRepository(Athlete::class)
->findBy(array('cin'=>$athlete->getCin()));
}
else{
$athlete=$this->getDoctrine()
->getRepository(Athlete::class)
->findAll();
}

return $this->render('@Athlete/Default/Recherche.html.twig',
array('f'=>$Form->createView(),'athlete'=>$athlete ));

PS: fel method hethi makhdouma ken fel input 7at cin y affichi l cin sinon y affichi ness l kol

Supprimer selon cin


function SupprimerAction($cin){
$em=$this->getDoctrine()->getManager();
$athlete=$this->getDoctrine()->getRepository(Athlete::class)
->find($cin);
$em->remove($athlete);
$em->flush();
return $this->redirectToRoute('affichera');
}

UPDATE
public function UpdateAction(Request $request, $cin){
$em=$this->getDoctrine()->getManager();
$athlete=$this->getDoctrine()
->getRepository(Athlete::class)
->find($cin);
$Form=$this->createForm(AthleteTestType::class,$athlete);
$Form->handleRequest($request);
if($Form->isSubmitted() ){
$em->flush();
return $this->redirectToRoute('calcul');

}
return $this->render('@Athlete/Default/update.html.twig',
array('f'=>$Form->createView()));
}
exemple ta3 methode moghta -_-
hné ken taux > 1 yaamel update lel etat l
1
public function testAction(Request $request, $cin){
$em=$this->getDoctrine()->getManager();
$athlete=$this->getDoctrine()
->getRepository(Athlete::class)
->find($cin);
$Form=$this->createForm(AthleteTestType::class,$athlete);
$Form->handleRequest($request);
if($Form->isSubmitted() ){
if(($athlete->getTauxD()>1) && ($athlete->getTestDopage()-
>getCodeTest()==1)){
$athlete->setEtat(1);
}

$em->flush();
return $this->redirectToRoute('calcul');

}
return $this->render('@Athlete/Default/test.html.twig',
array('f'=>$Form->createView(),'athlete'=>$athlete));
}

FAZET BEL TWIG TNAJEM TAAMALHOM FI 3ODUH DQL


hné exemple aana Entity Candidat w entity Sujet lézem n’affichi liste l candidat les sujets li ynajem
yaamalhom

ya3ni ken nombre de points mta3 sujet <= score mta3 candidat w ken description mta3 sujet
mawjouda ka mot clé aand l candidat n’affichi sujet
public function simulationAction($cin){
$em=$this->getDoctrine()->getManager();
$condidat=$this->getDoctrine()
->getRepository(Condidat::class)
->find($cin);

$sujets=$this->getDoctrine()->getRepository(Sujet::class)->findAll();

return $this->render('@These/These/simulation.html.twig',
array('condidat'=>$condidat,'sujets'=>$sujets));
}

liste des sujets adéquants au condidat: {{ condidat.nom }} {{ condidat.prenom }}

<ul>
{% for s in sujets %}
{% if s.nbpoints <= condidat.score and
condidat.motcle in s.description %}
<li class="ref">{{ s.reference}} {{ s.titre }} </li>

{% endif %}
{% endfor %}
</ul>
<button id="cl">Associer un sujet</button>

elli bel azre9 l condition mte3na

{% set i=0 %}
{% for a in athletes %}
{% if a.etat ==1 %}
{% set i=i+1 %}

{% endif %}
{% endfor %}

{{ i }} cas de dopage détectés sur {{ athletes|length }} tests en athlétisme

Hetheya exemple ekher yetaamal b twig


Ykharej affichage haka

Hetheya sans DQL affichage bel twig <3

GESTION MTA3 LES ERREURS

HETHI maanetha raw root mte3ek ghalet


donc
Lezmek tet2aked men hethom :
Tchouf rooting.yml

Tchouf fel Controller el render


Thabet men esm l fichier .twig

Erreur hethi lezmek thabet men esm l


method fel rooting.yml

Erreur hethi lezmek t’ajouti el SET mta3 l CIN ( clé


primaire) w tensech bech tnahi l auto increment
FORM type :.
$builder ->add('testDopage' , EntityType::class,array(
'class'=>'AthleteBundle:TestDopage',
'choice_label'=>'libelle'))
->add('tauxD')
->add('Effectuer un test',SubmitType::class);
;

Hné fel EntityType:class khaterha clé


etrangére donc naamloha akkeka l
choice_label bech t’affichi selon libelle
mouch id

IMPORTANT
KEN tlazzit bech taamel formtype ekher aala
nafs l Entity aamel new php class fel
FormType folder w mbaad aamel copier
coller lel method elli fi west el FormType
original mte3ek

Fazet fel FormTYpe:

BirthdayType::class Hetha ykharajlek


input bel date mel
year 1990
ChoiceType::class radio buttons
Expanded=true
Multiple=false
ChoiceType::class SELECT
Expanded=false
Multiple=false
ChoiceType::class checkboxes
Expanded=true
Multiple=true
Sinon rod belk mel copier coller rakzou mli7
w bonne chance w merci w e9blou na9d see
you tommorow 💙🍕🍕

PS: mafhemtech haja 9oli -_-

You might also like