Completed
Push — master ( a83b14...54219d )
by Yaroslav
18:18
created

src/Entity/Category.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Harentius\BlogBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Gedmo\Mapping\Annotation as Gedmo;
8
use Gedmo\Tree\Traits\NestedSetEntity;
9
use Harentius\BlogBundle\Entity\Base\IdentifiableEntityTrait;
10
use Harentius\BlogBundle\Entity\Base\SeoContentEntityTrait;
11
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface;
12
use Sonata\TranslationBundle\Traits\Translatable;
13
use Symfony\Component\Validator\Constraints as SymfonyConstraints;
14
15
/**
16
 * @Gedmo\Tree(type="nested")
17
 * @ORM\Entity(repositoryClass="Harentius\BlogBundle\Entity\CategoryRepository")
18
 */
19
class Category implements TranslatableInterface
20
{
21
    use IdentifiableEntityTrait;
22
    use NestedSetEntity;
23
    use SeoContentEntityTrait;
24
    use Translatable;
0 ignored issues
show
Deprecated Code introduced by
The trait Sonata\TranslationBundle\Traits\Translatable has been deprecated with message: since version 2.1 and will be removed in 3.0

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
25
26
    /**
27
     * @var string
28
     *
29
     * @ORM\Column(type="string", length=255)
30
     * @Gedmo\Translatable()
31
     * @SymfonyConstraints\Type(type="string")
32
     * @SymfonyConstraints\Length(max=255)
33
     * @SymfonyConstraints\NotBlank()
34
     */
35
    private $name;
36
37
    /**
38
     * @var string
39
     *
40
     * @ORM\Column(type="string", length=255)
41
     * @Gedmo\Slug(fields={"name"}, unique=true)
42
     * @SymfonyConstraints\Type(type="string")
43
     * @SymfonyConstraints\Length(max=255)
44
     */
45
    private $slug;
46
47
    /**
48
     * @var Article[]
49
     *
50
     * @ORM\OneToMany(
51
     *     targetEntity="Harentius\BlogBundle\Entity\Article",
52
     *     mappedBy="category",
53
     *     cascade={"remove"},
54
     * )
55
     */
56
    private $articles;
57
58
    /**
59
     * @var Category
60
     *
61
     * @Gedmo\TreeParent
62
     * @ORM\ManyToOne(
63
     *     targetEntity="Harentius\BlogBundle\Entity\Category",
64
     *     inversedBy="children"
65
     * )
66
     * @ORM\JoinColumn(referencedColumnName="id", onDelete="CASCADE")
67
     */
68
    private $parent;
69
70
    /**
71
     * @var Category[]
72
     *
73
     * @ORM\OneToMany(
74
     *     targetEntity="Harentius\BlogBundle\Entity\Category",
75
     *     mappedBy="parent"
76
     * )
77
     * @ORM\OrderBy({"left" = "ASC"})
78
     */
79
    private $children;
80
81
    /**
82
     *
83
     */
84
    public function __construct()
85
    {
86
        $this->articles = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type array<integer,object<Har...Bundle\Entity\Article>> of property $articles.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
87
        $this->children = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type array<integer,object<Har...undle\Entity\Category>> of property $children.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function __toString()
94
    {
95
        return $this->name;
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function getName()
102
    {
103
        return $this->name;
104
    }
105
106
    /**
107
     * @param string $value
108
     * @return $this
109
     */
110
    public function setName($value)
111
    {
112
        $this->name = $value;
113
114
        return $this;
115
    }
116
117
    /**
118
     * @return string
119
     */
120
    public function getSlug()
121
    {
122
        return $this->slug;
123
    }
124
125
    /**
126
     * @param string $value
127
     * @return $this
128
     */
129
    public function setSlug($value)
130
    {
131
        $this->slug = $value;
132
133
        return $this;
134
    }
135
136
    /**
137
     * @return Article[]|ArrayCollection
138
     */
139
    public function getArticles()
140
    {
141
        return $this->articles;
142
    }
143
144
    /**
145
     * @param Article[] $value
146
     * @return $this
147
     */
148
    public function setArticles($value)
149
    {
150
        $this->articles = $value;
151
152
        return $this;
153
    }
154
155
    /**
156
     * @return mixed
157
     */
158
    public function getParent()
159
    {
160
        return $this->parent;
161
    }
162
163
    /**
164
     * @param mixed $value
165
     * @return $this
166
     */
167
    public function setParent($value)
168
    {
169
        $this->parent = $value;
170
171
        return $this;
172
    }
173
174
    /**
175
     * @return Tag[]|ArrayCollection
176
     */
177
    public function getChildren()
178
    {
179
        return $this->children;
180
    }
181
182
    /**
183
     * @param Tag[] $value
184
     * @return $this
185
     */
186
    public function setChildren($value)
187
    {
188
        $this->children = $value;
0 ignored issues
show
Documentation Bug introduced by
It seems like $value of type array<integer,object<Har...BlogBundle\Entity\Tag>> is incompatible with the declared type array<integer,object<Har...undle\Entity\Category>> of property $children.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
189
190
        return $this;
191
    }
192
193
    /**
194
     * @return int
195
     */
196
    public function getLeft()
197
    {
198
        return $this->left;
199
    }
200
201
    /**
202
     * @param int $value
203
     * @return $this
204
     */
205
    public function setLeft($value)
206
    {
207
        $this->left = $value;
208
209
        return $this;
210
    }
211
212
    /**
213
     * @return int
214
     */
215
    public function getRight()
216
    {
217
        return $this->right;
218
    }
219
220
    /**
221
     * @param int $value
222
     * @return $this
223
     */
224
    public function setRight($value)
225
    {
226
        $this->right = $value;
227
228
        return $this;
229
    }
230
231
    /**
232
     * @return int
233
     */
234
    public function getRoot()
235
    {
236
        return $this->root;
237
    }
238
239
    /**
240
     * @param int $value
241
     * @return $this
242
     */
243
    public function setRoot($value)
244
    {
245
        $this->root = $value;
246
247
        return $this;
248
    }
249
}
250