aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Entity
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Config.php113
-rw-r--r--src/Wallabag/CoreBundle/Entity/User.php19
-rw-r--r--src/Wallabag/CoreBundle/Entity/UsersConfig.php123
3 files changed, 106 insertions, 149 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php
index 045ca308..7b4464a1 100644
--- a/src/Wallabag/CoreBundle/Entity/Config.php
+++ b/src/Wallabag/CoreBundle/Entity/Config.php
@@ -3,10 +3,12 @@
3namespace Wallabag\CoreBundle\Entity; 3namespace Wallabag\CoreBundle\Entity;
4 4
5use Doctrine\ORM\Mapping as ORM; 5use Doctrine\ORM\Mapping as ORM;
6use Symfony\Component\Validator\Constraints as Assert;
6 7
7/** 8/**
8 * Config 9 * Config
9 * 10 *
11 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\ConfigRepository")
10 * @ORM\Table(name="config") 12 * @ORM\Table(name="config")
11 * @ORM\Entity 13 * @ORM\Entity
12 */ 14 */
@@ -15,25 +17,50 @@ class Config
15 /** 17 /**
16 * @var integer 18 * @var integer
17 * 19 *
18 * @ORM\Column(name="id", type="integer", nullable=false) 20 * @ORM\Column(name="id", type="integer")
19 * @ORM\Id 21 * @ORM\Id
20 * @ORM\GeneratedValue(strategy="IDENTITY") 22 * @ORM\GeneratedValue(strategy="AUTO")
21 */ 23 */
22 private $id; 24 private $id;
23 25
24 /** 26 /**
25 * @var string 27 * @var string
26 * 28 *
27 * @ORM\Column(name="name", type="string", nullable=true) 29 * @Assert\NotBlank()
30 * @ORM\Column(name="theme", type="string", nullable=false)
28 */ 31 */
29 private $name; 32 private $theme;
30 33
31 /** 34 /**
32 * @var string 35 * @var string
33 * 36 *
34 * @ORM\Column(name="value", type="blob", nullable=true) 37 * @Assert\NotBlank()
38 * @ORM\Column(name="items_per_page", type="integer", nullable=false)
35 */ 39 */
36 private $value; 40 private $items_per_page;
41
42 /**
43 * @var string
44 *
45 * @Assert\NotBlank()
46 * @ORM\Column(name="language", type="string", nullable=false)
47 */
48 private $language;
49
50 /**
51 * @ORM\ManyToOne(targetEntity="User", inversedBy="config")
52 */
53 private $user;
54
55 /*
56 * @param User $user
57 */
58 public function __construct(User $user)
59 {
60 $this->user = $user;
61 $this->items_per_page = 12;
62 $this->language = 'en_US';
63 }
37 64
38 /** 65 /**
39 * Get id 66 * Get id
@@ -46,48 +73,94 @@ class Config
46 } 73 }
47 74
48 /** 75 /**
49 * Set name 76 * Set theme
50 * 77 *
51 * @param string $name 78 * @param string $theme
52 * @return Config 79 * @return Config
53 */ 80 */
54 public function setName($name) 81 public function setTheme($theme)
55 { 82 {
56 $this->name = $name; 83 $this->theme = $theme;
57 84
58 return $this; 85 return $this;
59 } 86 }
60 87
61 /** 88 /**
62 * Get name 89 * Get theme
63 * 90 *
64 * @return string 91 * @return string
65 */ 92 */
66 public function getName() 93 public function getTheme()
67 { 94 {
68 return $this->name; 95 return $this->theme;
69 } 96 }
70 97
71 /** 98 /**
72 * Set value 99 * Set items_per_page
73 * 100 *
74 * @param string $value 101 * @param integer $itemsPerPage
75 * @return Config 102 * @return Config
76 */ 103 */
77 public function setValue($value) 104 public function setItemsPerPage($itemsPerPage)
78 { 105 {
79 $this->value = $value; 106 $this->items_per_page = $itemsPerPage;
80 107
81 return $this; 108 return $this;
82 } 109 }
83 110
84 /** 111 /**
85 * Get value 112 * Get items_per_page
113 *
114 * @return integer
115 */
116 public function getItemsPerPage()
117 {
118 return $this->items_per_page;
119 }
120
121 /**
122 * Set language
123 *
124 * @param string $language
125 * @return Config
126 */
127 public function setLanguage($language)
128 {
129 $this->language = $language;
130
131 return $this;
132 }
133
134 /**
135 * Get language
86 * 136 *
87 * @return string 137 * @return string
88 */ 138 */
89 public function getValue() 139 public function getLanguage()
140 {
141 return $this->language;
142 }
143
144 /**
145 * Set user
146 *
147 * @param \Wallabag\CoreBundle\Entity\User $user
148 * @return Config
149 */
150 public function setUser(\Wallabag\CoreBundle\Entity\User $user = null)
151 {
152 $this->user = $user;
153
154 return $this;
155 }
156
157 /**
158 * Get user
159 *
160 * @return \Wallabag\CoreBundle\Entity\User
161 */
162 public function getUser()
90 { 163 {
91 return $this->value; 164 return $this->user;
92 } 165 }
93} 166}
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php
index c83250c3..193dfebc 100644
--- a/src/Wallabag/CoreBundle/Entity/User.php
+++ b/src/Wallabag/CoreBundle/Entity/User.php
@@ -6,6 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Symfony\Component\Security\Core\User\UserInterface; 7use Symfony\Component\Security\Core\User\UserInterface;
8use Symfony\Component\Security\Core\User\AdvancedUserInterface; 8use Symfony\Component\Security\Core\User\AdvancedUserInterface;
9use Symfony\Component\Validator\Constraints as Assert;
9 10
10/** 11/**
11 * User 12 * User
@@ -29,6 +30,11 @@ class User implements AdvancedUserInterface, \Serializable
29 * @var string 30 * @var string
30 * 31 *
31 * @ORM\Column(name="username", type="text") 32 * @ORM\Column(name="username", type="text")
33 * @Assert\NotBlank()
34 * @Assert\Length(
35 * min = "3",
36 * max = "255"
37 * )
32 */ 38 */
33 private $username; 39 private $username;
34 40
@@ -56,14 +62,16 @@ class User implements AdvancedUserInterface, \Serializable
56 /** 62 /**
57 * @var string 63 * @var string
58 * 64 *
59 * @ORM\Column(name="email", type="text", nullable=true) 65 * @ORM\Column(name="email", type="text", nullable=false)
66 * @Assert\Email()
67 * @Assert\NotBlank()
60 */ 68 */
61 private $email; 69 private $email;
62 70
63 /** 71 /**
64 * @ORM\Column(name="is_active", type="boolean") 72 * @ORM\Column(name="is_active", type="boolean", nullable=false)
65 */ 73 */
66 private $isActive; 74 private $isActive = true;
67 75
68 /** 76 /**
69 * @var date 77 * @var date
@@ -86,9 +94,8 @@ class User implements AdvancedUserInterface, \Serializable
86 94
87 public function __construct() 95 public function __construct()
88 { 96 {
89 $this->isActive = true; 97 $this->salt = md5(uniqid(null, true));
90 $this->salt = md5(uniqid(null, true)); 98 $this->entries = new ArrayCollection();
91 $this->entries = new ArrayCollection();
92 } 99 }
93 100
94 /** 101 /**
diff --git a/src/Wallabag/CoreBundle/Entity/UsersConfig.php b/src/Wallabag/CoreBundle/Entity/UsersConfig.php
deleted file mode 100644
index 0742edbc..00000000
--- a/src/Wallabag/CoreBundle/Entity/UsersConfig.php
+++ /dev/null
@@ -1,123 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6
7/**
8 * UsersConfig
9 *
10 * @ORM\Table(name="users_config")
11 * @ORM\Entity
12 */
13class UsersConfig
14{
15 /**
16 * @var integer
17 *
18 * @ORM\Column(name="id", type="integer", nullable=true)
19 * @ORM\Id
20 * @ORM\GeneratedValue(strategy="IDENTITY")
21 */
22 private $id;
23
24 /**
25 * @var string
26 *
27 * @ORM\Column(name="user_id", type="decimal", precision=10, scale=0, nullable=true)
28 */
29 private $userId;
30
31 /**
32 * @var string
33 *
34 * @ORM\Column(name="name", type="text", nullable=true)
35 */
36 private $name;
37
38 /**
39 * @var string
40 *
41 * @ORM\Column(name="value", type="text", nullable=true)
42 */
43 private $value;
44
45 /**
46 * Get id
47 *
48 * @return integer
49 */
50 public function getId()
51 {
52 return $this->id;
53 }
54
55 /**
56 * Set userId
57 *
58 * @param string $userId
59 * @return UsersConfig
60 */
61 public function setUserId($userId)
62 {
63 $this->userId = $userId;
64
65 return $this;
66 }
67
68 /**
69 * Get userId
70 *
71 * @return string
72 */
73 public function getUserId()
74 {
75 return $this->userId;
76 }
77
78 /**
79 * Set name
80 *
81 * @param string $name
82 * @return UsersConfig
83 */
84 public function setName($name)
85 {
86 $this->name = $name;
87
88 return $this;
89 }
90
91 /**
92 * Get name
93 *
94 * @return string
95 */
96 public function getName()
97 {
98 return $this->name;
99 }
100
101 /**
102 * Set value
103 *
104 * @param string $value
105 * @return UsersConfig
106 */
107 public function setValue($value)
108 {
109 $this->value = $value;
110
111 return $this;
112 }
113
114 /**
115 * Get value
116 *
117 * @return string
118 */
119 public function getValue()
120 {
121 return $this->value;
122 }
123}