Skip to content

Commit 9f39ec9

Browse files
committed
PhpFunction m2one User
1 parent 9dc9cbf commit 9f39ec9

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/Entity/PhpFunction.php

+15
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class PhpFunction
5858
)]
5959
private ?DateTimeInterface $updatedAt = null;
6060

61+
#[ORM\ManyToOne(inversedBy: 'phpFunctions')]
62+
private ?User $idUser = null;
63+
6164
public function getId(): ?int
6265
{
6366
return $this->id;
@@ -147,4 +150,16 @@ public function setUpdatedAt(?DateTimeInterface $updateAt): static
147150

148151
return $this;
149152
}
153+
154+
public function getIdUser(): ?User
155+
{
156+
return $this->idUser;
157+
}
158+
159+
public function setIdUser(?User $idUser): static
160+
{
161+
$this->idUser = $idUser;
162+
163+
return $this;
164+
}
150165
}

src/Entity/User.php

+43
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace App\Entity;
44

55
use App\Repository\UserRepository;
6+
use Doctrine\Common\Collections\ArrayCollection;
7+
use Doctrine\Common\Collections\Collection;
68
use Doctrine\DBAL\Types\Types;
79
use Doctrine\ORM\Mapping as ORM;
810
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
@@ -35,6 +37,17 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
3537
#[ORM\Column(type: Types::TEXT, nullable: true)]
3638
private ?string $description = null;
3739

40+
/**
41+
* @var Collection<int, PhpFunction>
42+
*/
43+
#[ORM\OneToMany(targetEntity: PhpFunction::class, mappedBy: 'idUser')]
44+
private Collection $phpFunctions;
45+
46+
public function __construct()
47+
{
48+
$this->phpFunctions = new ArrayCollection();
49+
}
50+
3851
public function getId(): ?int
3952
{
4053
return $this->id;
@@ -120,4 +133,34 @@ public function setDescription(?string $description): static
120133

121134
return $this;
122135
}
136+
137+
/**
138+
* @return Collection<int, PhpFunction>
139+
*/
140+
public function getPhpFunctions(): Collection
141+
{
142+
return $this->phpFunctions;
143+
}
144+
145+
public function addPhpFunction(PhpFunction $phpFunction): static
146+
{
147+
if (!$this->phpFunctions->contains($phpFunction)) {
148+
$this->phpFunctions->add($phpFunction);
149+
$phpFunction->setIdUser($this);
150+
}
151+
152+
return $this;
153+
}
154+
155+
public function removePhpFunction(PhpFunction $phpFunction): static
156+
{
157+
if ($this->phpFunctions->removeElement($phpFunction)) {
158+
// set the owning side to null (unless already changed)
159+
if ($phpFunction->getIdUser() === $this) {
160+
$phpFunction->setIdUser(null);
161+
}
162+
}
163+
164+
return $this;
165+
}
123166
}

0 commit comments

Comments
 (0)