Page::setTemplate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Beelab\SimplePageBundle\Entity;
4
5
use Beelab\SimplePageBundle\Validator\Constraints\NoExistingRoute as AssertNoExistingRoute;
6
use Doctrine\ORM\Mapping as ORM;
7
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * Page.
12
 *
13
 * @ORM\MappedSuperclass
14
 * @UniqueEntity(fields={"path"})
15
 */
16
class Page
17
{
18
    public static $templates = [
19
        'default' => 'default',
20
    ];
21
22
    /**
23
     * @var int|null
24
     *
25
     * @ORM\Column(type="integer")
26
     * @ORM\Id
27
     * @ORM\GeneratedValue(strategy="AUTO")
28
     */
29
    protected $id;
30
31
    /**
32
     * @var string|null
33
     *
34
     * @ORM\Column(options={"default": "default"})
35
     * @Assert\NotBlank()
36
     * @Assert\Regex(pattern="/^[ \w\-]+$/i")
37
     */
38
    protected $template = 'default';
39
40
    /**
41
     * @var string|null
42
     *
43
     * @ORM\Column(unique=true)
44
     * @Assert\NotBlank()
45
     * @Assert\Regex(pattern="/^[^\/][\w\/\-]+$/i")
46
     * @Assert\Length(max=255)
47
     * @AssertNoExistingRoute()
48
     */
49
    protected $path;
50
51
    /**
52
     * @var string|null
53
     *
54
     * @ORM\Column()
55
     * @Assert\NotBlank()
56
     * @Assert\Length(max=255)
57
     */
58
    protected $title;
59
60
    /**
61
     * @var string|null
62
     *
63
     * @ORM\Column(type="text")
64
     * @Assert\NotBlank()
65
     */
66
    protected $content;
67
68
    public function __toString(): string
69
    {
70
        return $this->title;
71
    }
72
73
    /**
74
     * @return int|null
75
     */
76
    public function getId()
77
    {
78
        return $this->id;
79
    }
80
81
    public function setTemplate(?string $template): self
82
    {
83
        $this->template = $template;
84
85
        return $this;
86
    }
87
88
    public function getTemplate(): ?string
89
    {
90
        return $this->template;
91
    }
92
93
    public function setPath(?string $path): self
94
    {
95
        $this->path = $path;
96
97
        return $this;
98
    }
99
100
    public function getPath(): ?string
101
    {
102
        return $this->path;
103
    }
104
105
    public function setTitle(?string $title): self
106
    {
107
        $this->title = $title;
108
109
        return $this;
110
    }
111
112
    public function getTitle(): ?string
113
    {
114
        return $this->title;
115
    }
116
117
    public function setContent(?string $content): self
118
    {
119
        $this->content = $content;
120
121
        return $this;
122
    }
123
124
    public function getContent(): ?string
125
    {
126
        return $this->content;
127
    }
128
}
129