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 :

error mappig symfony2 [2.x]


Sujet :

Symfony PHP

  1. #1
    Membre éprouvé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Novembre 2013
    Messages
    739
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Novembre 2013
    Messages : 739
    Points : 1 022
    Points
    1 022
    Par défaut error mappig symfony2
    Bonjour;
    J'ai une entité Menu OneToMany avec l'entité rubrique . j'ai inseré quelque instance (menu et rubrique)
    Quand je veux supprimer un Menu une exception se leve !

    Whoops, looks like something went wrong.
    1/1ContextErrorException: Notice: Undefined index: Rubrique in C:\wamp\www\ProjetWeb\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php line 1608


    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
    <?php
     
    namespace MyApp\EspritBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Menu
     *
     * @ORM\Table()
     * @ORM\Entity
     */
    class Menu
    {
        /**
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @ORM\OneToMany(targetEntity="Rubrique", mappedBy="menu", cascade={"remove", "persist"})
         */
        protected $rubriques;
     
     
        /**
         * @ORM\ManyToOne(targetEntity="Utilisateur", inversedBy="menus")
         * @ORM\JoinColumn(name="utilisateur_id", referencedColumnName="id",nullable=false)
         */
     
       protected $utilisateur;
        /**
         * @var integer
         *
         * @ORM\Column(name="position", type="integer",unique=true)
         */
        private $position;
     
        /**
         * @var string
         *
         * @ORM\Column(name="title", type="string", length=255,unique=true)
         */
        private $title;
     
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set position
         *
         * @param integer $position
         * @return Menu
         */
        public function setPosition($position)
        {
            $this->position = $position;
     
            return $this;
        }
     
        /**
         * Get position
         *
         * @return integer 
         */
        public function getPosition()
        {
            return $this->position;
        }
     
        /**
         * Set title
         *
         * @param string $title
         * @return Menu
         */
        public function setTitle($title)
        {
            $this->title = $title;
     
            return $this;
        }
     
        /**
         * Get title
         *
         * @return string 
         */
        public function getTitle()
        {
            return $this->title;
        }
            public function getRubriques() {
            return $this->rubriques;
        }
     
        public function setRubriques($rubriques) {
            $this->rubriques = $rubriques;
        }
          public function getUtilisateur() {
            return $this->utilisateur;
        }
     
        public function setUtilisateur($utilisateur) {
            $this->utilisateur = $utilisateur;
        }
     
          public function __toString()
        {
              return $this->nom.'' ;
        }
     
    }
    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
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    <?php
     
    namespace MyApp\EspritBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Rubrique
     *
     * @ORM\Table(name="Rub")
     * @ORM\Entity
     */
    class Rubrique
    {
     
     
     
        /**
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @ORM\OneToMany(targetEntity="SousRubrique", mappedBy="Rubrique", cascade={"remove", "persist"})
         */
        protected $sousrubriques;    
        /**
         * @ORM\OneToMany(targetEntity="Article", mappedBy="Rubrique")
         */
        protected $articles;
     
        /**
         * @ORM\ManyToOne(targetEntity="Menu", inversedBy="rubriques")
         * @ORM\JoinColumn(name="menu_id", referencedColumnName="id",nullable=false)
         */
        protected $menu;
     
     
        /**
         * @var integer
         *
         * @ORM\Column(name="position", type="integer")
         */
        private $position;
     
        /**
         * @var boolean
         *
         * @ORM\Column(name="state", type="boolean")
         */
        private $state;
     
        /**
         * @var string
         *
         * @ORM\Column(name="title", type="string", length=255,unique=true)
         */
        private $title;
     
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set position
         *
         * @param integer $position
         * @return Rubrique
         */
        public function setPosition($position)
        {
            $this->position = $position;
     
            return $this;
        }
     
        /**
         * Get position
         *
         * @return integer 
         */
        public function getPosition()
        {
            return $this->position;
        }
     
        /**
         * Set state
         *
         * @param boolean $state
         * @return Rubrique
         */
        public function setState($state)
        {
            $this->state = $state;
     
            return $this;
        }
     
        /**
         * Get state
         *
         * @return boolean 
         */
        public function getState()
        {
            return $this->state;
        }
     
        /**
         * Set title
         *
         * @param string $title
         * @return Rubrique
         */
        public function setTitle($title)
        {
            $this->title = $title;
     
            return $this;
        }
     
        /**
         * Get title
         *
         * @return string 
         */
        public function getTitle()
        {
            return $this->title;
        }
          public function getMenu() {
            return $this->menu;
        }
     
        public function setMenu($menu) {
            $this->menu = $menu;
        }
       public function getSousrubriques() {
            return $this->sousrubriques;
        }
     
        public function setSousrubriques($sousrubriques) {
            $this->sousrubriques = $sousrubriques;
        }
         public function getArticles() {
            return $this->articles;
        }
     
        public function setArticles($articles) {
            $this->articles = $articles;
        }
     
          public function __toString()
        {
              return $this->title.'' ; 
        }
     
    }
    merci d'avance

  2. #2
    Membre habitué
    Homme Profil pro
    Inscrit en
    Août 2012
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2012
    Messages : 98
    Points : 163
    Points
    163
    Par défaut
    Je dirais sans conviction qu'il faut préciser que c'est une arrayCollection

  3. #3
    Membre expérimenté Avatar de Nico_F
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2011
    Messages
    728
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Avril 2011
    Messages : 728
    Points : 1 310
    Points
    1 310
    Par défaut
    Je dirais avec un peu plus de conviction que quelque part t'as du vouloir récupérer tes rubriques à la sortie d'un form, ou de quelque chose qui s'apparente à un tableau et que tu as mis 'rubrique' à la place de 'rubriques'.

  4. #4
    Membre éprouvé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Novembre 2013
    Messages
    739
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Novembre 2013
    Messages : 739
    Points : 1 022
    Points
    1 022
    Par défaut
    merci pour la reponse,j'ai toujours mis rubrique sans S partout :/

  5. #5
    Membre éprouvé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Novembre 2013
    Messages
    739
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Novembre 2013
    Messages : 739
    Points : 1 022
    Points
    1 022
    Par défaut
    voila mes form

    MenuType:
    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
    <?php
     
    namespace MyApp\EspritBundle\Form;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\OptionsResolver\OptionsResolverInterface;
     
    class MenuType extends AbstractType
    {
            /**
         * @param FormBuilderInterface $builder
         * @param array $options
         */
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $builder
                ->add('position')
                ->add('title')
     
     
     
             ->add('utilisateur', 'entity', array('class' => 'MyApp\EspritBundle\Entity\Utilisateur',     
              'property' => 'nom',
              'expanded' => false,
              'multiple' => false,
              'required' => true ) 
     
            );
        }
     
        /**
         * @param OptionsResolverInterface $resolver
         */
        public function setDefaultOptions(OptionsResolverInterface $resolver)
        {
            $resolver->setDefaults(array(
                'data_class' => 'MyApp\EspritBundle\Entity\Menu'
            ));
        }
     
        /**
         * @return string
         */
        public function getName()
        {
            return 'myapp_espritbundle_menu';
        }
    }
    RubriqueType:
    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
    <?php
     
    namespace MyApp\EspritBundle\Form;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\OptionsResolver\OptionsResolverInterface;
     
    class RubriqueType extends AbstractType
    {
            /**
         * @param FormBuilderInterface $builder
         * @param array $options
         */
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $builder
                ->add('position')
                ->add('state', 'checkbox', array('required' => false,'data' => true))
                ->add('title')
     
     
     
            ->add('menu', 'entity', array('class' => 'MyApp\EspritBundle\Entity\Menu',     
              'property' => 'title',
              'expanded' => false,
              'multiple' => false,
              'required' => true 
     
     
     
           ) );
        }
     
        /**
         * @param OptionsResolverInterface $resolver
         */
        public function setDefaultOptions(OptionsResolverInterface $resolver)
        {
            $resolver->setDefaults(array(
                'data_class' => 'MyApp\EspritBundle\Entity\Rubrique'
            ));
        }
     
        /**
         * @return string
         */
        public function getName()
        {
            return 'myapp_espritbundle_rubrique';
        }
    }

  6. #6
    Membre expérimenté Avatar de Nico_F
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2011
    Messages
    728
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Avril 2011
    Messages : 728
    Points : 1 310
    Points
    1 310
    Par défaut
    Citation Envoyé par mehrezlabidimehrez Voir le message
    merci pour la reponse,j'ai toujours mis rubrique sans S partout :/
    Sauf dans ton entité Menu manifestement.

  7. #7
    Membre éprouvé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Novembre 2013
    Messages
    739
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Novembre 2013
    Messages : 739
    Points : 1 022
    Points
    1 022
    Par défaut
    j'ai corrigé les annotations, certains sont inutiles et cause le desordre .
    merci a tous vos propositions.

    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
    <?php
     
    namespace MyApp\EspritBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Menu
     *
     * @ORM\Table()
     * @ORM\Entity
     */
    class Menu
    {
        /**
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
     
        protected $rubriques;
     
     
        /**
         * @ORM\ManyToOne(targetEntity="Utilisateur", inversedBy="menus")
         * @ORM\JoinColumn(name="utilisateur_id", referencedColumnName="id",nullable=false)
         */
     
       protected $utilisateur;
        /**
         * @var integer
         *
         * @ORM\Column(name="position", type="integer",unique=true)
         */
        private $position;
     
        /**
         * @var string
         *
         * @ORM\Column(name="title", type="string", length=255,unique=true)
         */
        private $title;
     
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set position
         *
         * @param integer $position
         * @return Menu
         */
        public function setPosition($position)
        {
            $this->position = $position;
     
            return $this;
        }
     
        /**
         * Get position
         *
         * @return integer 
         */
        public function getPosition()
        {
            return $this->position;
        }
     
        /**
         * Set title
         *
         * @param string $title
         * @return Menu
         */
        public function setTitle($title)
        {
            $this->title = $title;
     
            return $this;
        }
     
        /**
         * Get title
         *
         * @return string 
         */
        public function getTitle()
        {
            return $this->title;
        }
            public function getRubriques() {
            return $this->rubriques;
        }
     
        public function setRubriques($rubriques) {
            $this->rubriques = $rubriques;
        }
          public function getUtilisateur() {
            return $this->utilisateur;
        }
     
        public function setUtilisateur($utilisateur) {
            $this->utilisateur = $utilisateur;
        }
     
          public function __toString()
        {
              return $this->nom.'' ;
        }
     
    }
    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
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    <?php
     
    namespace MyApp\EspritBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Rubrique
     *
     * @ORM\Table(name="Rub")
     * @ORM\Entity
     */
    class Rubrique
    {
     
     
     
        /**
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
     
        protected $sousrubriques;    
     
        protected $articles;
     
        /**
         * @ORM\ManyToOne(targetEntity="MyApp\EspritBundle\Entity\Menu")
         * @ORM\JoinColumn(name="menu_id", referencedColumnName="id",nullable=false, onDelete="CASCADE")
         */
        protected $menu;
     
     
        /**
         * @var integer
         *
         * @ORM\Column(name="position", type="integer")
         */
        private $position;
     
        /**
         * @var boolean
         *
         * @ORM\Column(name="state", type="boolean")
         */
        private $state;
     
        /**
         * @var string
         *
         * @ORM\Column(name="title", type="string", length=255,unique=true)
         */
        private $title;
     
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set position
         *
         * @param integer $position
         * @return Rubrique
         */
        public function setPosition($position)
        {
            $this->position = $position;
     
            return $this;
        }
     
        /**
         * Get position
         *
         * @return integer 
         */
        public function getPosition()
        {
            return $this->position;
        }
     
        /**
         * Set state
         *
         * @param boolean $state
         * @return Rubrique
         */
        public function setState($state)
        {
            $this->state = $state;
     
            return $this;
        }
     
        /**
         * Get state
         *
         * @return boolean 
         */
        public function getState()
        {
            return $this->state;
        }
     
        /**
         * Set title
         *
         * @param string $title
         * @return Rubrique
         */
        public function setTitle($title)
        {
            $this->title = $title;
     
            return $this;
        }
     
        /**
         * Get title
         *
         * @return string 
         */
        public function getTitle()
        {
            return $this->title;
        }
          public function getMenu() {
            return $this->menu;
        }
     
        public function setMenu($menu) {
            $this->menu = $menu;
        }
       public function getSousrubriques() {
            return $this->sousrubriques;
        }
     
        public function setSousrubriques($sousrubriques) {
            $this->sousrubriques = $sousrubriques;
        }
         public function getArticles() {
            return $this->articles;
        }
     
        public function setArticles($articles) {
            $this->articles = $articles;
        }
     
          public function __toString()
        {
              return $this->title.'' ; 
        }
     
    }

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

Discussions similaires

  1. Réponses: 12
    Dernier message: 12/06/2014, 14h44
  2. Réponses: 1
    Dernier message: 15/04/2014, 22h56
  3. Error 500 + 1and1 + Symfony2
    Par Adraesh dans le forum Hébergement
    Réponses: 0
    Dernier message: 09/06/2012, 16h10
  4. [CR] Print Engine error text
    Par afaraji dans le forum SAP Crystal Reports
    Réponses: 1
    Dernier message: 03/09/2002, 15h44
  5. [Kylix] Runtime error 230 avec INDY
    Par Anonymous dans le forum EDI
    Réponses: 2
    Dernier message: 23/03/2002, 11h51

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