Skip to content

Commit 18d9a1e

Browse files
committed
l m2m P
1 parent 47a5e17 commit 18d9a1e

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

src/Entity/LinkPhp.php

+45-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
namespace App\Entity;
44

55
use App\Repository\LinkPhpRepository;
6+
use Doctrine\Common\Collections\ArrayCollection;
7+
use Doctrine\Common\Collections\Collection;
8+
use Doctrine\DBAL\Types\Types;
69
use Doctrine\ORM\Mapping as ORM;
710

811
#[ORM\Entity(repositoryClass: LinkPhpRepository::class)]
912
class LinkPhp
1013
{
1114
#[ORM\Id]
1215
#[ORM\GeneratedValue]
13-
#[ORM\Column]
16+
#[ORM\Column(
17+
type: Types::INTEGER,
18+
options: ['unsigned' => true]
19+
)]
1420
private ?int $id = null;
1521

1622
#[ORM\Column(length: 150)]
@@ -22,6 +28,17 @@ class LinkPhp
2228
#[ORM\Column(length: 255)]
2329
private ?string $Url = null;
2430

31+
/**
32+
* @var Collection<int, PhpFunction>
33+
*/
34+
#[ORM\ManyToMany(targetEntity: PhpFunction::class, mappedBy: 'Link')]
35+
private Collection $phpFunctions;
36+
37+
public function __construct()
38+
{
39+
$this->phpFunctions = new ArrayCollection();
40+
}
41+
2542
public function getId(): ?int
2643
{
2744
return $this->id;
@@ -62,4 +79,31 @@ public function setUrl(string $Url): static
6279

6380
return $this;
6481
}
82+
83+
/**
84+
* @return Collection<int, PhpFunction>
85+
*/
86+
public function getPhpFunctions(): Collection
87+
{
88+
return $this->phpFunctions;
89+
}
90+
91+
public function addPhpFunction(PhpFunction $phpFunction): static
92+
{
93+
if (!$this->phpFunctions->contains($phpFunction)) {
94+
$this->phpFunctions->add($phpFunction);
95+
$phpFunction->addLink($this);
96+
}
97+
98+
return $this;
99+
}
100+
101+
public function removePhpFunction(PhpFunction $phpFunction): static
102+
{
103+
if ($this->phpFunctions->removeElement($phpFunction)) {
104+
$phpFunction->removeLink($this);
105+
}
106+
107+
return $this;
108+
}
65109
}

src/Entity/PhpFunction.php

+37
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
namespace App\Entity;
55

66
use App\Repository\PhpFunctionRepository;
7+
use Doctrine\Common\Collections\ArrayCollection;
8+
use Doctrine\Common\Collections\Collection;
79
use Doctrine\DBAL\Types\Types;
810
use Doctrine\ORM\Mapping as ORM;
911
# Timestamp
@@ -61,6 +63,17 @@ class PhpFunction
6163
#[ORM\ManyToOne(inversedBy: 'phpFunctions')]
6264
private ?User $idUser = null;
6365

66+
/**
67+
* @var Collection<int, LinkPhp>
68+
*/
69+
#[ORM\ManyToMany(targetEntity: LinkPhp::class, inversedBy: 'phpFunctions')]
70+
private Collection $Link;
71+
72+
public function __construct()
73+
{
74+
$this->Link = new ArrayCollection();
75+
}
76+
6477
public function getId(): ?int
6578
{
6679
return $this->id;
@@ -162,4 +175,28 @@ public function setIdUser(?User $idUser): static
162175

163176
return $this;
164177
}
178+
179+
/**
180+
* @return Collection<int, LinkPhp>
181+
*/
182+
public function getLink(): Collection
183+
{
184+
return $this->Link;
185+
}
186+
187+
public function addLink(LinkPhp $link): static
188+
{
189+
if (!$this->Link->contains($link)) {
190+
$this->Link->add($link);
191+
}
192+
193+
return $this;
194+
}
195+
196+
public function removeLink(LinkPhp $link): static
197+
{
198+
$this->Link->removeElement($link);
199+
200+
return $this;
201+
}
165202
}

0 commit comments

Comments
 (0)