DDC-2255: [Doctrine-Bridge][Console] Entity, Getters and Setters Generating Bug detected in Symfony 2 Framework #2836

Closed
opened 2026-01-22 14:05:23 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 24, 2013).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user nayzo:

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() !

Originally created by @doctrinebot on GitHub (Jan 24, 2013). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user nayzo: ### Bug found when generation the Entity, Getters and Setters by using the Command: ``` none > 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: ``` 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; } ``` 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()** !
admin added the Bug label 2026-01-22 14:05:23 +01:00
admin closed this issue 2026-01-22 14:05:24 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 24, 2013):

Comment created by @ocramius:

[~nayzo] This is expected behavior, since the generator should not change already existing methods

@doctrinebot commented on GitHub (Jan 24, 2013): Comment created by @ocramius: [~nayzo] This is expected behavior, since the generator should not change already existing methods
Author
Owner

@doctrinebot commented on GitHub (Jan 24, 2013):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jan 24, 2013): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Jan 24, 2013):

Comment created by nayzo:

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 !!

@doctrinebot commented on GitHub (Jan 24, 2013): Comment created by nayzo: 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 !!
Author
Owner

@doctrinebot commented on GitHub (Jan 24, 2013):

Comment created by @ocramius:

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.

@doctrinebot commented on GitHub (Jan 24, 2013): Comment created by @ocramius: 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2836