Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: ORM
    • Labels:
      None
    • Environment:
      php 5.4.3, symfony2.1-dev
      php 5.5.12, symfony 2.5

      Description

      When a trait with included setters and getters is used and generate entities is called, doctrine add another set of getters and setters to the "main" entity where the trait is used.

        Activity

        Matthias Breddin created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Workflow jira [ 13708 ] jira-feedback [ 14067 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14067 ] jira-feedback2 [ 15931 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 15931 ] jira-feedback3 [ 18182 ]
        Alexander made changes -
        Issue Type Bug [ 1 ] Improvement [ 4 ]
        Hide
        Martin Aarhof added a comment - - edited
        /**
         * @ORM\Entity
         */
        class Product {
            use Traits\Created;
        
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="integer")
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            private $id;
        
            /**
             * @var string
             *
             * @ORM\Column(name="name", type="string", length=255)
             */
            private $name;
        
            /**
             * Set name
             *
             * @param string $name
             * @return Attribute
             */
            public function setName($name)
            {
                $this->name = $name;
        
                return $this;
            }
        
            /**
             * Get name
             *
             * @return string 
             */
            public function getName()
            {
                return $this->name;
            }
        
        }
        
        Trait Created {
            /**
             * @var \DateTime $created
             *
             * @Gedmo\Timestampable(on="create")
             * @ORM\Column(type="datetime")
             */
            private $created;
        
            /**
             * @return \DateTime
             */
            public function getCreated()
            {
                return $this->created;
            }
        }
        

        Now when I run php app/console doctrine:generate:entities it copies everything from the trait and into the entity, so the entity now looks like

        /**
         * @ORM\Entity
         */
        class Product {
            use Traits\Created;
        
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="integer")
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            private $id;
        
            /**
             * @var string
             *
             * @ORM\Column(name="name", type="string", length=255)
             */
            private $name;
        
            /**
             * Set name
             *
             * @param string $name
             * @return Attribute
             */
            public function setName($name)
            {
                $this->name = $name;
        
                return $this;
            }
        
            /**
             * Get name
             *
             * @return string 
             */
            public function getName()
            {
                return $this->name;
            }
        
            /**
             * @var \DateTime $created
             *
             * @Gedmo\Timestampable(on="create")
             * @ORM\Column(type="datetime")
             */
            private $created;
        
            /**
             * @return \DateTime
             */
            public function getCreated()
            {
                return $this->created;
            }
        
        }
        

        And ofcourse invalidates the entity because it now has two methods of the getCreated and two of private $created

        Show
        Martin Aarhof added a comment - - edited /** * @ORM\Entity */ class Product { use Traits\Created; /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="string", length=255) */ private $name; /** * Set name * * @param string $name * @return Attribute */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } } Trait Created { /** * @var \DateTime $created * * @Gedmo\Timestampable(on="create") * @ORM\Column(type="datetime") */ private $created; /** * @return \DateTime */ public function getCreated() { return $this->created; } } Now when I run php app/console doctrine:generate:entities it copies everything from the trait and into the entity, so the entity now looks like /** * @ORM\Entity */ class Product { use Traits\Created; /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="string", length=255) */ private $name; /** * Set name * * @param string $name * @return Attribute */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } /** * @var \DateTime $created * * @Gedmo\Timestampable(on="create") * @ORM\Column(type="datetime") */ private $created; /** * @return \DateTime */ public function getCreated() { return $this->created; } } And ofcourse invalidates the entity because it now has two methods of the getCreated and two of private $created
        Martin Aarhof made changes -
        Priority Minor [ 4 ] Major [ 3 ]
        Martin Aarhof made changes -
        Environment php 5.4.3, symfony2.1-dev php 5.4.3, symfony2.1-dev
        php 5.5.12, symfony 2.5

        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-1825, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Matthias Breddin
          • Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: