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\CategoryRepository") |
12
|
|
|
*/ |
13
|
|
|
class Category extends AbstractAppEntity |
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\OneToMany(targetEntity="App\Entity\Trick", mappedBy="category") |
29
|
|
|
*/ |
30
|
|
|
private $tricks; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @ORM\Column(type="string", length=255, unique=true) |
34
|
|
|
* @Gedmo\Slug(fields={"Name"}) |
35
|
|
|
*/ |
36
|
|
|
private $slug; |
37
|
|
|
|
38
|
|
|
public function __construct() |
39
|
|
|
{ |
40
|
|
|
$this->tricks = 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
|
|
|
/** |
61
|
|
|
* @return Collection|Trick[] |
62
|
|
|
*/ |
63
|
|
|
public function getTricks(): Collection |
64
|
|
|
{ |
65
|
|
|
return $this->tricks; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function addTrick(Trick $trick): self |
69
|
|
|
{ |
70
|
|
|
if (!$this->tricks->contains($trick)) { |
71
|
|
|
$this->tricks[] = $trick; |
72
|
|
|
$trick->setCategory($this); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function removeTrick(Trick $trick): self |
79
|
|
|
{ |
80
|
|
|
if ($this->tricks->contains($trick)) { |
81
|
|
|
$this->tricks->removeElement($trick); |
82
|
|
|
// set the owning side to null (unless already changed) |
83
|
|
|
if ($trick->getCategory() === $this) { |
84
|
|
|
$trick->setCategory(null); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return $this; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function __toString(){ |
92
|
|
|
return $this->Name; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function getSlug(): ?string |
96
|
|
|
{ |
97
|
|
|
return $this->slug; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function setSlug(string $slug): self |
101
|
|
|
{ |
102
|
|
|
$this->slug = $slug; |
103
|
|
|
|
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|