Completed
Push — master ( c4f3a1...40a960 )
by Benjamin
02:13
created

Node::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Alpixel\Bundle\CMSBundle\Entity;
4
5
use Alpixel\Bundle\SEOBundle\Entity\MetaTagPlaceholderInterface;
6
use Doctrine\ORM\Mapping as ORM;
7
use Gedmo\Mapping\Annotation as Gedmo;
8
9
/**
10
 * Page.
11
 *
12
 * @ORM\Table(name="cms_node")
13
 * @ORM\HasLifecycleCallbacks
14
 * @ORM\Entity(repositoryClass="Alpixel\Bundle\CMSBundle\Entity\Repository\NodeRepository")
15
 */
16
class Node implements MetaTagPlaceholderInterface
17
{
18
    /**
19
     * @var int
20
     *
21
     * @ORM\Column(name="node_id", type="integer")
22
     * @ORM\Id
23
     * @ORM\GeneratedValue(strategy="AUTO")
24
     */
25
    protected $id;
26
27
    /**
28
     * @var string
29
     *
30
     * @ORM\Column(name="locale", type="string", length=10, nullable=true)
31
     */
32
    protected $locale;
33
34
    /**
35
     * @var \Alpixel\Bundle\CMSBundle\Entity\Node
36
     *
37
     * @ORM\ManyToOne(targetEntity="Alpixel\Bundle\CMSBundle\Entity\Node")
38
     * @ORM\JoinColumn(name="translation_source_id",referencedColumnName="node_id", nullable=true, onDelete="SET NULL")
39
     */
40
    protected $translationSource;
41
42
    /**
43
     * @var string
44
     *
45
     * @ORM\Column(name="title", type="string", length=255, nullable=false)
46
     */
47
    protected $title;
48
49
    /**
50
     * @var string
51
     *
52
     * @ORM\Column(name="type", type="string", length=255, nullable=false)
53
     */
54
    protected $type;
55
56
    /**
57
     * @var string
58
     *
59
     * @ORM\Column(name="content", type="text", nullable=true)
60
     */
61
    protected $content;
62
63
    /**
64
     * @var \DateTime
65
     *
66
     * @Gedmo\Timestampable(on="create")
67
     * @ORM\Column(name="date_created", type="datetime", nullable=false)
68
     */
69
    protected $dateCreated;
70
71
    /**
72
     * @var \DateTime
73
     * @Gedmo\Timestampable(on="update")
74
     * @ORM\Column(name="date_updated", type="datetime", nullable=false)
75
     */
76
    protected $dateUpdated;
77
78
    /**
79
     * @var bool
80
     *
81
     * @ORM\Column(name="published", type="boolean", nullable=false, options={"default"= true})
82
     */
83
    protected $published;
84
85
    /**
86
     * @var int
87
     * @Gedmo\SortablePosition
88
     * @ORM\Column(name="position", type="integer", nullable=false)
89
     */
90
    protected $position;
91
92
    /**
93
     * @Gedmo\Slug(fields={"title"}, updatable=false, separator="_")
94
     * @ORM\Column(length=128, unique=true)
95
     **/
96
    protected $slug;
97
98
    public function __construct()
99
    {
100
    }
101
102
    public function __clone()
103
    {
104
        $this->id = null;
105
        $this->dateCreated = null;
106
        $this->dateUpdated = null;
107
        $this->position = null;
108
        $this->slug = null;
109
    }
110
111
    public function getUriParameters()
112
    {
113
        return [
114
            'id'            => $this->id,
115
            'slug'          => $this->slug,
116
        ];
117
    }
118
119
    public function getPlaceholders()
120
    {
121
        return [
122
            '[cms:title]'  => $this->title,
123
            '[cms:resume]' => substr(strip_tags($this->content), 0, 150),
124
        ];
125
    }
126
127
    public function __toString()
128
    {
129
        return $this->title;
130
    }
131
132
    /**
133
     * Gets the value of id.
134
     *
135
     * @return int
136
     */
137
    public function getId()
138
    {
139
        return $this->id;
140
    }
141
142
    /**
143
     * Sets the value of id.
144
     *
145
     * @param int $id the id
146
     *
147
     * @return self
148
     */
149
    public function setId($id)
150
    {
151
        $this->id = $id;
152
153
        return $this;
154
    }
155
156
    /**
157
     * Gets the value of title.
158
     *
159
     * @return string
160
     */
161
    public function getTitle()
162
    {
163
        return $this->title;
164
    }
165
166
    /**
167
     * Sets the value of title.
168
     *
169
     * @param string $title the title
170
     *
171
     * @return self
172
     */
173
    public function setTitle($title)
174
    {
175
        $this->title = $title;
176
177
        return $this;
178
    }
179
180
    /**
181
     * Gets the value of content.
182
     *
183
     * @return string
184
     */
185
    public function getContent()
186
    {
187
        return $this->content;
188
    }
189
190
    /**
191
     * Sets the value of content.
192
     *
193
     * @param string $content the content
194
     *
195
     * @return self
196
     */
197
    public function setContent($content)
198
    {
199
        $this->content = $content;
200
201
        return $this;
202
    }
203
204
    /**
205
     * Gets the value of dateCreated.
206
     *
207
     * @return \DateTime
208
     */
209
    public function getDateCreated()
210
    {
211
        return $this->dateCreated;
212
    }
213
214
    /**
215
     * Sets the value of dateCreated.
216
     *
217
     * @param \DateTime $dateCreated the date created
218
     *
219
     * @return self
220
     */
221
    public function setDateCreated(\DateTime $dateCreated)
222
    {
223
        $this->dateCreated = $dateCreated;
224
225
        return $this;
226
    }
227
228
    /**
229
     * Gets the value of dateUpdated.
230
     *
231
     * @return \DateTime
232
     */
233
    public function getDateUpdated()
234
    {
235
        return $this->dateUpdated;
236
    }
237
238
    /**
239
     * Sets the value of dateUpdated.
240
     *
241
     * @param \DateTime $dateUpdated the date updated
242
     *
243
     * @return self
244
     */
245
    public function setDateUpdated(\DateTime $dateUpdated)
246
    {
247
        $this->dateUpdated = $dateUpdated;
248
249
        return $this;
250
    }
251
252
    /**
253
     * Gets the value of published.
254
     *
255
     * @return bool
256
     */
257
    public function getPublished()
258
    {
259
        return $this->published;
260
    }
261
262
    /**
263
     * Sets the value of published.
264
     *
265
     * @param bool $published the published
266
     *
267
     * @return self
268
     */
269
    public function setPublished($published)
270
    {
271
        $this->published = $published;
272
273
        return $this;
274
    }
275
276
    /**
277
     * Gets the value of position.
278
     *
279
     * @return int
280
     */
281
    public function getPosition()
282
    {
283
        return $this->position;
284
    }
285
286
    /**
287
     * Sets the value of position.
288
     *
289
     * @param int $position the position
290
     *
291
     * @return self
292
     */
293
    public function setPosition($position)
294
    {
295
        $this->position = $position;
296
297
        return $this;
298
    }
299
300
    /**
301
     * Gets the value of slug.
302
     *
303
     * @return mixed
304
     */
305
    public function getSlug()
306
    {
307
        return $this->slug;
308
    }
309
310
    /**
311
     * Sets the value of slug.
312
     *
313
     * @param mixed $slug the slug
314
     *
315
     * @return self
316
     */
317
    public function setSlug($slug)
318
    {
319
        $this->slug = $slug;
320
321
        return $this;
322
    }
323
324
    /**
325
     * Gets the value of type.
326
     *
327
     * @return string
328
     */
329
    public function getType()
330
    {
331
        return $this->type;
332
    }
333
334
    /**
335
     * Sets the value of type.
336
     *
337
     * @param string $type the type
338
     *
339
     * @return self
340
     */
341
    public function setType($type)
342
    {
343
        $this->type = $type;
344
345
        return $this;
346
    }
347
348
    /**
349
     * Gets the value of locale.
350
     *
351
     * @return string
352
     */
353
    public function getLocale()
354
    {
355
        return $this->locale;
356
    }
357
358
    /**
359
     * Sets the value of locale.
360
     *
361
     * @param string $locale the locale
362
     *
363
     * @return self
364
     */
365
    public function setLocale($locale)
366
    {
367
        $this->locale = $locale;
368
369
        return $this;
370
    }
371
372
    /**
373
     * Gets the value of translationSource.
374
     *
375
     * @return \Alpixel\Bundle\CMSBundle\Entity\Node
376
     */
377
    public function getTranslationSource()
378
    {
379
        return $this->translationSource;
380
    }
381
382
    /**
383
     * Sets the value of translationSource.
384
     *
385
     * @param \Alpixel\Bundle\CMSBundle\Entity\Node $translationSource the translation source
386
     *
387
     * @return self
388
     */
389
    public function setTranslationSource(\Alpixel\Bundle\CMSBundle\Entity\Node $translationSource)
390
    {
391
        $this->translationSource = $translationSource;
392
393
        return $this;
394
    }
395
}
396