Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2255

[Doctrine-Bridge][Console] Entity, Getters and Setters Generating Bug detected in Symfony 2 Framework

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:

      Description

      Bug found when generation the Entity, Getters and Setters by using the Command:

      > php app/console doctrine:generate:entities YourBundleBundle:YourEntity 
      

      In the situation you have a OneToMany relation in the Entity and you did implement the __construct(), then the Console Wont generate the ArrayCollection() !
      In the case you did not implement the __construct(), then everything will goes fine when generating them,
      Example:

      /**
       * @ORM\OneToMany(targetEntity=" YourBundleBundle \Entity\ YourEntity ", mappedBy=" YourEntity ")
       */
      private $YourAttribut;
      
      public function __construct()
      {
        $this-> YourAttribut = new \Doctrine\Common\Collections\ArrayCollection();
      } 
      // But in the case you did implement the __construct() before using the Command, let say like this:
      
      public function __construct()
      {
        $this-> YourOtherAttribut = a_value;
      } 
      

      In this case, when using the Command to generate Entity, Getters and Setters, the Console Wont generate the ArrayCollection() of the OneToMany relations in the __construct() !

        Activity

        Ala Eddine Khefifi created issue -
        Ala Eddine Khefifi made changes -
        Field Original Value New Value
        Description h3. Bug found when generation the Entity, Getters and Setters by using the Command:
        {code:none}
        > php app/console doctrine:generate:entities YourBundleBundle:YourEntity
        {code}
        In the situation you have a *OneToMany* relation in the Entity and you did implement the *__construct()*, then the Console *Wont* generate the *ArrayCollection()* !
        In the case you did not implement the *__construct()*, then everything will goes fine when generating them,
        Example:
        {code:none}
        /**
         * @ORM\OneToMany(targetEntity=" YourBundleBundle \Entity\ YourEntity ", mappedBy=" YourEntity ")
         */
        private $YourAttribut;

        public function __construct()
        {
          $this-> YourAttribut = new \Doctrine\Common\Collections\ArrayCollection();
        }
        // But in the case you did implement the __construct() before using the Command, let say like this:

        public function __construct()
        {
          $this-> YourOtherAttribut = a_value;
        }
        {code}
        In this case, when using the Command to generate Entity, Getters and Setters, the Console *Wont* generate the *ArrayCollection()* of the *OneToMany* relations in the *__construct()* !
        h3. Bug found when generation the Entity, Getters and Setters by using the Command:

        {code:none}
        > php app/console doctrine:generate:entities YourBundleBundle:YourEntity
        {code}
        In the situation you have a *OneToMany* relation in the Entity and you did implement the *__construct()*, then the Console *Wont* generate the *ArrayCollection()* !
        In the case you did not implement the *__construct()*, then everything will goes fine when generating them,
        Example:
        {code:none}
        /**
         * @ORM\OneToMany(targetEntity=" YourBundleBundle \Entity\ YourEntity ", mappedBy=" YourEntity ")
         */
        private $YourAttribut;

        public function __construct()
        {
          $this-> YourAttribut = new \Doctrine\Common\Collections\ArrayCollection();
        }
        // But in the case you did implement the __construct() before using the Command, let say like this:

        public function __construct()
        {
          $this-> YourOtherAttribut = a_value;
        }
        {code}
        In this case, when using the Command to generate Entity, Getters and Setters, the Console *Wont* generate the *ArrayCollection()* of the *OneToMany* relations in the *__construct()* !
        Hide
        Marco Pivetta added a comment -

        Ala Eddine Khefifi This is expected behavior, since the generator should not change already existing methods

        Show
        Marco Pivetta added a comment - Ala Eddine Khefifi This is expected behavior, since the generator should not change already existing methods
        Marco Pivetta made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Benjamin Eberlei [ beberlei ] Marco Pivetta [ ocramius ]
        Resolution Invalid [ 6 ]
        Hide
        Ala Eddine Khefifi added a comment -

        but it could override them and add missing instruction that should be added within the code, otherwise it leads to a dis-function and non stable relations !!

        Show
        Ala Eddine Khefifi added a comment - but it could override them and add missing instruction that should be added within the code, otherwise it leads to a dis-function and non stable relations !!
        Hide
        Marco Pivetta added a comment -

        No, that is not up to the generator. Entity generation and fixing your broken existing code are different things. You should not rely on the generator to handle this kind of problems, the generator just gives you a kick-start, but after that, you are on your own.

        Show
        Marco Pivetta added a comment - No, that is not up to the generator. Entity generation and fixing your broken existing code are different things. You should not rely on the generator to handle this kind of problems, the generator just gives you a kick-start, but after that, you are on your own.

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2255, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Ala Eddine Khefifi
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: