-
-
Notifications
You must be signed in to change notification settings - Fork 438
Closed
Labels
BugBug FixBug Fix
Description
Hello,
I have one entity Organization with a team property
class RefOrganization
/**
* One Organization has One team
* @ORM\OneToOne(targetEntity="RefTeam", mappedBy="organization")
*/
private $team;
I have a second entity Team with a Organization property
class RefTeam
/**
* One Team has one Organization
* @ORM\OneToOne(targetEntity="RefOrganization", inversedBy="team")
* @ORM\JoinColumn(name="ORGANIZATION_ID", referencedColumnName="ID", nullable=true)
*/
private $organization;
With the following code, I got a OneToOne relationship between both entities.
However, when lauching the Make:Entity --regenerate to get back all setters / getters,
In the RefOrganization entity, it generates the following setter for the team :
public function setTeam(?RefTeam $team): self
{
$this->team = $team;
// set (or unset) the owning side of the relation if necessary
$newOrganization = $team === null ? null : $this;
if ($newOrganization !== $team->getOrganization()) {
$team->setOrganization($newOrganization);
}
return $this;
}
When creating the RefOrganization without team (as it's nullable), we have an error because of the :
if ($newOrganization !== $team->getOrganization())
call method getOrganization of null object
Regards
elementaire, miroslav-chandler, Dawen18, imodi, yizhihouzi and 3 more
Metadata
Metadata
Assignees
Labels
BugBug FixBug Fix