1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\MenuBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Kunstmaan\AdminBundle\Entity\AbstractEntity; |
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class BaseMenu |
12
|
|
|
* |
13
|
|
|
* @ORM\MappedSuperclass() |
14
|
|
|
*/ |
15
|
|
|
class BaseMenu extends AbstractEntity |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
* |
20
|
|
|
* @ORM\Column(name="name", type="string", length=25, nullable=true) |
21
|
|
|
* @Assert\NotBlank() |
22
|
|
|
*/ |
23
|
|
|
protected $name; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
* |
28
|
|
|
* @ORM\Column(name="locale", type="string", length=5, nullable=true) |
29
|
|
|
* @Assert\NotBlank() |
30
|
|
|
*/ |
31
|
|
|
protected $locale; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var ArrayCollection |
35
|
|
|
* |
36
|
|
|
* @ORM\OneToMany(targetEntity="Kunstmaan\MenuBundle\Entity\MenuItem", mappedBy="menu", cascade={"persist", "remove"}, orphanRemoval=true) |
37
|
|
|
*/ |
38
|
|
|
protected $items; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Constructor |
42
|
|
|
*/ |
43
|
2 |
|
public function __construct() |
44
|
|
|
{ |
45
|
2 |
|
$this->items = new ArrayCollection(); |
46
|
2 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
1 |
|
public function getName() |
52
|
|
|
{ |
53
|
1 |
|
return $this->name; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $name |
58
|
|
|
* |
59
|
|
|
* @return Menu |
60
|
|
|
*/ |
61
|
1 |
|
public function setName($name) |
62
|
|
|
{ |
63
|
1 |
|
$this->name = $name; |
64
|
|
|
|
65
|
1 |
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
1 |
|
public function getLocale() |
72
|
|
|
{ |
73
|
1 |
|
return $this->locale; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $locale |
78
|
|
|
* |
79
|
|
|
* @return Menu |
80
|
|
|
*/ |
81
|
1 |
|
public function setLocale($locale) |
82
|
|
|
{ |
83
|
1 |
|
$this->locale = $locale; |
84
|
|
|
|
85
|
1 |
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return ArrayCollection |
90
|
|
|
*/ |
91
|
1 |
|
public function getItems() |
92
|
|
|
{ |
93
|
1 |
|
return $this->items; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param ArrayCollection $items |
98
|
|
|
* |
99
|
|
|
* @return Menu |
100
|
|
|
*/ |
101
|
1 |
|
public function setItems($items) |
102
|
|
|
{ |
103
|
1 |
|
$this->items = $items; |
104
|
|
|
|
105
|
1 |
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param MenuItem $item |
110
|
|
|
*/ |
111
|
1 |
|
public function addItem(MenuItem $item) |
112
|
|
|
{ |
113
|
1 |
|
$item->setMenu($this); |
|
|
|
|
114
|
|
|
|
115
|
1 |
|
$this->items->add($item); |
116
|
1 |
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param MenuItem $item |
120
|
|
|
*/ |
121
|
1 |
|
public function removeItem(MenuItem $item) |
122
|
|
|
{ |
123
|
1 |
|
$this->items->removeElement($item); |
124
|
1 |
|
} |
125
|
|
|
} |
126
|
|
|
|
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.