IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

Class App\Form\AbsencesJustif does not exist


Sujet :

Symfony PHP

  1. #1
    Membre du Club
    Homme Profil pro
    Assistant aux utilisateurs
    Inscrit en
    Janvier 2018
    Messages
    299
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Assistant aux utilisateurs
    Secteur : Distribution

    Informations forums :
    Inscription : Janvier 2018
    Messages : 299
    Points : 67
    Points
    67
    Par défaut Class App\Form\AbsencesJustif does not exist
    Bonjour,
    J'ai l'erreur suivante :
    Class App\Form\AbsencesJustif does not exist
    Seulement "AbsencesJustif" est une entité, je ne comprends pas pourquoi il va le chercher dans "FORM".

    Mon JustifAbscence à l'origine de l'erreur ligne 38(dans src/Form)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    <?php
     
    namespace App\Form;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\OptionsResolver\OptionsResolver;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\Form\Extension\Core\Type\TextType;
    use Symfony\Component\Form\Extension\Core\Type\PasswordType;
    use Symfony\Component\Form\Extension\Core\Type\SubmitType;
    use Symfony\Component\Form\Extension\Core\Type\TextareaType;
    use Symfony\Bridge\Doctrine\Form\Type\EntityType;
     
    use App\Entity\Pointage;
    use App\Entity\Cours;
    use App\Entity\PlageHoraire;
    use App\Entity\AbscencesJustif;
     
    class JustifAbscence extends AbstractType
    {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
        $formation = $options['formation'];
     
        // $formation = $this->getDoctrine()->getRepository(Formation::class)->find($idFormation);
     
        $builder
            ->add('cours', EntityType::class, array(
              'class' => Cours::class,
              'label' => false,
              'placeholder' => 'Cours',
              'required' => true,
              'choice_label' => 'nomUe',
              'choices' => $formation->getCours(),
              'attr' => array('class' => 'custom-select')
            ))
            ->add('plageHoraireJustif', EntityType::class, array(
              'class' => AbsencesJustif::class,
              'label' => false,
              'placeholder' => 'Plage horaire',
              'required' => true,
              'choice_label' => 'plageHoraireJustifAbscence',
              'attr' => array('class' => 'custom-select')
            ))
          /*  ->add('plageHoraire', EntityType::class, array(
              'class' => "",
              'label' => false,
              'placeholder' => 'add file',
              'required' => true,
              'required' => 'input',
              'choice_label' => 'addFile',
              'attr' => array('class' => 'custom-select')
            ))*/
            ->add('connection', SubmitType::class, array('label' => 'Justifier l\'absence', 'attr' => array('class' => 'btn btn-primary text-uppercase ml-2 px-5')));
      }
     
      public function configureOptions(OptionsResolver $resolver)
      {
        $resolver
        ->setDefaults([
            'data_class' => Pointage::class,
        ])
        ->setRequired(['formation']);
      }
    }
    mon entité (src/Entity/AbscencesJustif)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
     
    <?php
     
    namespace App\Entity;
     
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\Common\Collections\Collection;
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * @ORM\Entity(repositoryClass="App\Repository\PointageRepository")
     */
    class AbscencesJustif
    {
        /**
         * @ORM\Id()
         * @ORM\GeneratedValue()
         * @ORM\Column(type="integer")
         */
        private $id;
     
        /**
         * @ORM\ManyToOne(targetEntity="App\Entity\Cours", inversedBy="pointage")
         * @ORM\JoinColumn(nullable=false)
         */
        private $cours;
     
        /**
         * @ORM\ManyToOne(targetEntity="App\Entity\PlageHoraire", inversedBy="pointage")
         * @ORM\JoinColumn(nullable=false)
         */
        private $plageHoraireJustifAbscence;
     
        /**
         * @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur", inversedBy="pointage")
         */
        private $utilisateurEtudiant;
     
        /**
         * @ORM\ManyToOne(targetEntity="App\Entity\Formation", inversedBy="pointages")
         * @ORM\JoinColumn(nullable=false)
         */
        private $formation;
     
     
        /**
         * @ORM\Column(type="boolean")
         */
        private $lien_fichier;
     
        public function __construct()
        {
     
        }
     
        public function getId(): ?int
        {
            return $this->id;
        }
     
        public function getDateJustif(): ?\DateTimeInterface
        {
            return $this->dateJustif;
        }
     
        public function setDateJustif(\DateTimeInterface $dateJustif): self
        {
            $this->dateJustif = $dateJustif;
     
            return $this;
        }
     
        public function getCours(): ?Cours
        {
            return $this->cours;
        }
     
        public function setCours(?Cours $cours): self
        {
            $this->cours = $cours;
     
            return $this;
        }
     
        public function getUtilisateurEtudiant(): ?Utilisateur
        {
            return $this->utilisateurEtudiant;
        }
     
        public function setUtilisateurEtudiant(?Utilisateur $utilisateurEtudiant): self
        {
            $this->utilisateurEtudiant = $utilisateurEtudiant;
     
            return $this;
        }
        public function getPlageHoraireJustifAbscence(): ?PlageHoraire
        {
            return $this->plageHoraireJustifAbscence;
        }
     
        public function setPlageHoraireJustifAbscence(?PlageHoraire $plageHoraireJustifAbscence): self
        {
            $this->plageHoraireJustifAbscence = $plageHoraireJustifAbscence;
     
            return $this;
        }
     
        public function getFichierJustification(): ?bool
        {
            return $this->lien_fichier;
        }
     
        public function setFichierJustification(bool $lien_fichier): self
        {
            $this->lien_fichier = $lien_fichier;
     
            return $this;
        }
        public function getFormation(): ?Formation
        {
            return $this->formation;
        }
     
        public function setFormation(?Formation $formation): self
        {
            $this->formation = $formation;
     
            return $this;
        }
     
     
    }
    Merci d'avance

  2. #2
    Membre averti
    Homme Profil pro
    Inscrit en
    Mai 2004
    Messages
    803
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 803
    Points : 356
    Points
    356
    Par défaut
    L'erreur est générée pas quoi? Ton controller?

    Ce serait peut-être utile d'avoir le code de celui-ci...

  3. #3
    Membre du Club
    Homme Profil pro
    Assistant aux utilisateurs
    Inscrit en
    Janvier 2018
    Messages
    299
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Assistant aux utilisateurs
    Secteur : Distribution

    Informations forums :
    Inscription : Janvier 2018
    Messages : 299
    Points : 67
    Points
    67
    Par défaut
    Oui, de la fonction "justifierAbscence()":
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
     
    <?php
     
    namespace App\Controller;
     
    use Doctrine\ORM\EntityManagerInterface;
    use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\Validator\Constraints\DateTime;
    use Symfony\Component\HttpFoundation\Session\Session;
     
    use App\Entity\Pointage;
    use App\Entity\PlageHoraire;
    use App\Entity\Utilisateur;
    use App\Entity\AbscencesJustif;
     
    use App\Form\JustifAbscence;
    use App\Form\PointageNullType;
    use App\Form\PointageDeSortieType;
     
    use DateTimeImmutable;
     
    class PanelEtudiantController extends AbstractController
    {
      public function panelEtudiant()
      {
        $user = $this->getUser();
        $utilisateurEtudiant = $this->getDoctrine()->getRepository(Utilisateur::class)->find($user);
        $idPointage = $this->getDoctrine()->getRepository(Pointage::class)->findPointageSortieByEtudiant($utilisateurEtudiant);
        if($idPointage != null){
          $pointageExistant = $this->getDoctrine()->getRepository(Pointage::class)->find($idPointage[0]);
          $cours = $pointageExistant->getCours();
          return $this->render('panelEtudiant.html.twig', array('message' => 'Vous avez pointé en entrée de cours :', 'cours' => $cours, 'prenom' => $user->getPrenomUtilisateur(), 'nom' => $user->getNomUtilisateur()));
        } else {
          return $this->render('panelEtudiant.html.twig', array('message' => 'Vous n\'avez pas de pointage pour le moment', 'cours' =>'', 'prenom' => $user->getPrenomUtilisateur(), 'nom' => $user->getNomUtilisateur()));
        }
      }
      public function justifierAbscence(Request $request, EntityManagerInterface $em): Response
      {
        //$session = $this->get('session');
        $user = $this->getUser();
        $abscence_justif = new AbscencesJustif();
        //$user = $this->getDoctrine()->getRepository(Utilisateur::class)->find($id);
        $idPointage = $this->getDoctrine()->getRepository(AbscencesJustif::class)->findPointageSortieByEtudiant($user);
        $idPointageNull = $this->getDoctrine()->getRepository(AbscencesJustif::class)->findPointageByEtudiant($user);
     
        $formation = $user->getFormation();
     
        $form = $this->createForm(JustifAbscence::class, $abscence_justif, ['formation' => $formation]);
     
        $form->handleRequest($request);
     
        if ($form->isSubmitted() && $form->isValid()) {
          $abscence_justif = $form->getData();
          $cours = $form['cours']->getData()->getNomUe();
          $plageHoraireJustifAbscence = $form['plageHoraireJustifAbscence']->getData()->getPlageHoraireJustifAbscence();
          $tab = explode("h", $plageHoraireJustifAbscence, 2);
          $pointageTemporaire = new \DateTime();
          $abscence_justif->setFormation($formation);
          $abscence_justif->setUtilisateurEtudiant($user);
     
          $em = $this->getDoctrine()->getManager();
          $em->persist($abscence_justif);
          $em->flush();
     
          return $this->redirectToRoute('panelEtudiant');
        }
        return $this->render('panelEtudiantJustifierAbscence.twig', [
            'nom' => $user->getNomUtilisateur(),
            'prenom' => $user->getPrenomUtilisateur(),
            'form'=>$form->createView(),
        ]);
     
      }
     
    }
    Screen de l'erreur :
    Nom : aaaa.png
Affichages : 1400
Taille : 63,7 Ko

    Merci d'avance

  4. #4
    Membre averti
    Homme Profil pro
    Inscrit en
    Mai 2004
    Messages
    803
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 803
    Points : 356
    Points
    356
    Par défaut
    Pourrais-tu montrer le code de ton entité 'JustifAbscence '?

  5. #5
    Membre du Club
    Homme Profil pro
    Assistant aux utilisateurs
    Inscrit en
    Janvier 2018
    Messages
    299
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Assistant aux utilisateurs
    Secteur : Distribution

    Informations forums :
    Inscription : Janvier 2018
    Messages : 299
    Points : 67
    Points
    67
    Par défaut
    Je n'en ai pas.
    L'entité que j'utilise est "AbscencesJustif".
    Dans src/Form/ j'utilise "JustifAbscence".
    Je pense que c'est quelque chose qui cloche ici, mais comme je maîtrise mal Symfony pour le moment, je pense qu'il y a un pb que je ne vois pas.
    merci d'avance

  6. #6
    Membre régulier
    Homme Profil pro
    Développeur Web
    Inscrit en
    Décembre 2011
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2011
    Messages : 72
    Points : 107
    Points
    107
    Par défaut
    Il y a une typo dans la déclaration du champ de ton formulaire
    Tu fais un use App\Entity\AbsCencesJustif; (avec un C, qui est le nom correct de ta classe)
    Puis tu déclare le champ avec la classe AbsencesJustif (sans le C, qui n'est pas une classe qui existe)

  7. #7
    Membre du Club
    Homme Profil pro
    Assistant aux utilisateurs
    Inscrit en
    Janvier 2018
    Messages
    299
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Assistant aux utilisateurs
    Secteur : Distribution

    Informations forums :
    Inscription : Janvier 2018
    Messages : 299
    Points : 67
    Points
    67
    Par défaut
    Autant pour moi c'était simplement ça, je pensais à un problème bien plus important... merci, sujet résolu!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 09/04/2013, 09h35
  2. [WD17] API : RegisterWindowMessageA : class does not exist
    Par chapeau_melon dans le forum WinDev
    Réponses: 0
    Dernier message: 24/01/2013, 12h03
  3. Réponses: 4
    Dernier message: 29/03/2012, 16h43
  4. Form Bean does not exist
    Par libuma dans le forum Struts 1
    Réponses: 5
    Dernier message: 18/03/2010, 09h51
  5. System.Windows.Forms does not exist
    Par Morgoth818 dans le forum Windows Forms
    Réponses: 3
    Dernier message: 29/08/2008, 16h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo