1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\Common\Collections\Collection; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\TagRepository") |
12
|
|
|
*/ |
13
|
|
|
class Tag |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @ORM\Id() |
17
|
|
|
* @ORM\GeneratedValue() |
18
|
|
|
* @ORM\Column(type="integer") |
19
|
|
|
*/ |
20
|
|
|
private $id; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @ORM\Column(type="string", length=255) |
24
|
|
|
*/ |
25
|
|
|
private $name; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @ORM\Column(type="string", length=255, unique=true) |
29
|
|
|
* @Gedmo\Slug(fields={"name"}) |
30
|
|
|
*/ |
31
|
|
|
private $slug; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @ORM\ManyToMany(targetEntity="App\Entity\Trick", mappedBy="tags", cascade={"persist"}) |
35
|
|
|
*/ |
36
|
|
|
private $trick; |
37
|
|
|
|
38
|
|
|
public function __construct() |
39
|
|
|
{ |
40
|
|
|
$this->trick = new ArrayCollection(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getId(): ?int |
44
|
|
|
{ |
45
|
|
|
return $this->id; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getName(): ?string |
49
|
|
|
{ |
50
|
|
|
return $this->name; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function setName(string $name): self |
54
|
|
|
{ |
55
|
|
|
$this->name = $name; |
56
|
|
|
|
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getSlug(): ?string |
61
|
|
|
{ |
62
|
|
|
return $this->slug; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function setSlug(string $slug): self |
66
|
|
|
{ |
67
|
|
|
$this->slug = $slug; |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return Collection|Trick[] |
74
|
|
|
*/ |
75
|
|
|
public function getTrick(): Collection |
76
|
|
|
{ |
77
|
|
|
return $this->trick; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return Collection|Trick[] |
82
|
|
|
*/ |
83
|
|
|
public function getTricks(): Collection |
84
|
|
|
{ |
85
|
|
|
return $this->trick; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function addTrick(Trick $trick): self |
89
|
|
|
{ |
90
|
|
|
if (!$this->trick->contains($trick)) { |
91
|
|
|
$this->trick[] = $trick; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function removeTrick(Trick $trick): self |
98
|
|
|
{ |
99
|
|
|
if ($this->trick->contains($trick)) { |
100
|
|
|
$this->trick->removeElement($trick); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function __toString() |
107
|
|
|
{ |
108
|
|
|
return $this->name; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|