1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Webcook\Cms\I18nBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Webcook\Cms\CoreBundle\Base\BasicEntity; |
7
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Language entity used for translations and routing. |
12
|
|
|
* |
13
|
|
|
* @ORM\Entity |
14
|
|
|
* @ORM\Table(name="Language") |
15
|
|
|
* @ApiResource |
16
|
|
|
*/ |
17
|
|
|
class Language extends BasicEntity |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @ORM\Column(name="title", type="string", length=55) |
21
|
|
|
* @Assert\NotBlank |
22
|
|
|
* @Assert\NotNull |
23
|
|
|
*/ |
24
|
|
|
private $title; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @ORM\Column(name="locale", type="string", length=2) |
28
|
|
|
* @Assert\NotBlank |
29
|
|
|
* @Assert\NotNull |
30
|
|
|
*/ |
31
|
|
|
private $locale; |
32
|
|
|
|
33
|
|
|
/** @ORM\Column(name="isDefault", type="boolean") */ |
34
|
|
|
private $default = false; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Set locale of a language. |
38
|
|
|
* |
39
|
|
|
* @param String $locale locale of a language. |
40
|
|
|
* |
41
|
|
|
* @return Language Returns self. |
42
|
|
|
*/ |
43
|
14 |
|
public function setLocale($locale) |
44
|
|
|
{ |
45
|
14 |
|
$this->locale = $locale; |
46
|
|
|
|
47
|
14 |
|
return $this; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get locale. |
52
|
|
|
* |
53
|
|
|
* @return String Returns locale of language. |
54
|
|
|
*/ |
55
|
14 |
|
public function getLocale() |
56
|
|
|
{ |
57
|
14 |
|
return $this->locale; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Set whether language is default or not. |
62
|
|
|
* |
63
|
|
|
* @param String $default Default of a language. |
64
|
|
|
* |
65
|
|
|
* @return Language Returns self. |
66
|
|
|
*/ |
67
|
14 |
|
public function setDefault($default) |
68
|
|
|
{ |
69
|
14 |
|
$this->default = $default; |
|
|
|
|
70
|
|
|
|
71
|
14 |
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get whether language is default or not. |
76
|
|
|
* |
77
|
|
|
* @return boolean Returns if language is default. |
78
|
|
|
*/ |
79
|
4 |
|
public function isDefault() |
80
|
|
|
{ |
81
|
4 |
|
return $this->default; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Gets the value of title. |
86
|
|
|
* |
87
|
|
|
* @return mixed |
88
|
|
|
*/ |
89
|
4 |
|
public function getTitle() |
90
|
|
|
{ |
91
|
4 |
|
return $this->title; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Sets the value of title. |
96
|
|
|
* |
97
|
|
|
* @param string $title the title |
98
|
|
|
* |
99
|
|
|
* @return self |
100
|
|
|
*/ |
101
|
14 |
|
public function setTitle($title) |
102
|
|
|
{ |
103
|
14 |
|
$this->title = $title; |
104
|
|
|
|
105
|
14 |
|
return $this; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.