|
3 | 3 | namespace App\Entity;
|
4 | 4 |
|
5 | 5 | use App\Repository\UserRepository;
|
| 6 | +use Doctrine\Common\Collections\ArrayCollection; |
| 7 | +use Doctrine\Common\Collections\Collection; |
6 | 8 | use Doctrine\DBAL\Types\Types;
|
7 | 9 | use Doctrine\ORM\Mapping as ORM;
|
8 | 10 | use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
@@ -35,6 +37,17 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
35 | 37 | #[ORM\Column(type: Types::TEXT, nullable: true)]
|
36 | 38 | private ?string $description = null;
|
37 | 39 |
|
| 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 | + |
38 | 51 | public function getId(): ?int
|
39 | 52 | {
|
40 | 53 | return $this->id;
|
@@ -120,4 +133,34 @@ public function setDescription(?string $description): static
|
120 | 133 |
|
121 | 134 | return $this;
|
122 | 135 | }
|
| 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 | + } |
123 | 166 | }
|
0 commit comments