diff options
author | Thomas Citharel <tcit@tcit.fr> | 2017-05-31 09:31:18 +0200 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2017-06-23 10:08:54 +0200 |
commit | bf6c0346d8d35a719dd1bff1cb4d573d422f99ff (patch) | |
tree | 04fb80e20ad1cffacb72357a632a9afe2ec058cb /src/Wallabag/FederationBundle/Entity | |
parent | d6d3f4ec3698effd1d4b063e295341791bdcf7d7 (diff) | |
download | wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.tar.gz wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.tar.zst wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.zip |
WIPfederation
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'src/Wallabag/FederationBundle/Entity')
-rw-r--r-- | src/Wallabag/FederationBundle/Entity/Account.php | 307 | ||||
-rw-r--r-- | src/Wallabag/FederationBundle/Entity/Instance.php | 111 |
2 files changed, 418 insertions, 0 deletions
diff --git a/src/Wallabag/FederationBundle/Entity/Account.php b/src/Wallabag/FederationBundle/Entity/Account.php new file mode 100644 index 00000000..c44050d9 --- /dev/null +++ b/src/Wallabag/FederationBundle/Entity/Account.php | |||
@@ -0,0 +1,307 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\FederationBundle\Entity; | ||
4 | |||
5 | use Doctrine\Common\Collections\ArrayCollection; | ||
6 | use Doctrine\Common\Collections\Collection; | ||
7 | use Doctrine\ORM\Mapping as ORM; | ||
8 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | ||
9 | use Symfony\Component\Validator\Constraints as Assert; | ||
10 | use Wallabag\CoreBundle\Entity\Entry; | ||
11 | use Wallabag\UserBundle\Entity\User; | ||
12 | |||
13 | /** | ||
14 | * Account. | ||
15 | * | ||
16 | * @ORM\Entity(repositoryClass="Wallabag\FederationBundle\Repository\AccountRepository") | ||
17 | * @UniqueEntity(fields={"username", "server"}). | ||
18 | * @ORM\Table(name="`account`") | ||
19 | */ | ||
20 | class Account | ||
21 | { | ||
22 | /** | ||
23 | * @var int | ||
24 | * | ||
25 | * @ORM\Column(name="id", type="integer") | ||
26 | * @ORM\Id | ||
27 | * @ORM\GeneratedValue(strategy="AUTO") | ||
28 | * | ||
29 | */ | ||
30 | private $id; | ||
31 | |||
32 | /** | ||
33 | * @var string | ||
34 | * | ||
35 | * @ORM\Column(name="username", type="string") | ||
36 | */ | ||
37 | private $username; | ||
38 | |||
39 | /** | ||
40 | * @var Instance | ||
41 | * | ||
42 | * @ORM\ManyToOne(targetEntity="Wallabag\FederationBundle\Entity\Instance", inversedBy="users") | ||
43 | */ | ||
44 | private $server; | ||
45 | |||
46 | /** | ||
47 | * @var User | ||
48 | * | ||
49 | * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="account") | ||
50 | * @ORM\JoinColumn(nullable=true) | ||
51 | */ | ||
52 | private $user; | ||
53 | |||
54 | /** | ||
55 | * @var ArrayCollection | ||
56 | * | ||
57 | * @ORM\ManyToMany(targetEntity="Wallabag\FederationBundle\Entity\Account", mappedBy="following") | ||
58 | */ | ||
59 | private $followers; | ||
60 | |||
61 | /** | ||
62 | * @var ArrayCollection | ||
63 | * | ||
64 | * @ORM\ManyToMany(targetEntity="Wallabag\FederationBundle\Entity\Account", inversedBy="followers") | ||
65 | * @ORM\JoinTable(name="follow", | ||
66 | * joinColumns={@ORM\JoinColumn(name="account_id", referencedColumnName="id")}, | ||
67 | * inverseJoinColumns={@ORM\JoinColumn(name="follow_account_id", referencedColumnName="id")} | ||
68 | * ) | ||
69 | */ | ||
70 | private $following; | ||
71 | |||
72 | /** | ||
73 | * @var string | ||
74 | * | ||
75 | * @ORM\Column(type="string", nullable=true) | ||
76 | * | ||
77 | * @Assert\File(mimeTypes={ "image/gif", "image/jpeg", "image/svg+xml", "image/webp", "image/png" }) | ||
78 | */ | ||
79 | private $avatar; | ||
80 | |||
81 | /** | ||
82 | * @var string | ||
83 | * | ||
84 | * @ORM\Column(type="string", nullable=true) | ||
85 | * | ||
86 | * @Assert\File(mimeTypes={ "image/gif", "image/jpeg", "image/svg+xml", "image/webp", "image/png" }) | ||
87 | */ | ||
88 | private $banner; | ||
89 | |||
90 | /** | ||
91 | * @var string | ||
92 | * | ||
93 | * @ORM\Column(type="text", nullable=true) | ||
94 | */ | ||
95 | private $description; | ||
96 | |||
97 | /** | ||
98 | * Account constructor. | ||
99 | */ | ||
100 | public function __construct() | ||
101 | { | ||
102 | $this->followers = new ArrayCollection(); | ||
103 | $this->following = new ArrayCollection(); | ||
104 | $this->liked = new ArrayCollection(); | ||
105 | } | ||
106 | |||
107 | /** | ||
108 | * @return int | ||
109 | */ | ||
110 | public function getId() | ||
111 | { | ||
112 | return $this->id; | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * @return string | ||
117 | */ | ||
118 | public function getUsername() | ||
119 | { | ||
120 | return $this->username; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * @param string $username | ||
125 | * @return Account | ||
126 | */ | ||
127 | public function setUsername($username) | ||
128 | { | ||
129 | $this->username = $username; | ||
130 | return $this; | ||
131 | } | ||
132 | |||
133 | /** | ||
134 | * @return string | ||
135 | */ | ||
136 | public function getServer() | ||
137 | { | ||
138 | return $this->server; | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * @param string $server | ||
143 | * @return Account | ||
144 | */ | ||
145 | public function setServer($server) | ||
146 | { | ||
147 | $this->server = $server; | ||
148 | return $this; | ||
149 | } | ||
150 | |||
151 | /** | ||
152 | * @return User | ||
153 | */ | ||
154 | public function getUser() | ||
155 | { | ||
156 | return $this->user; | ||
157 | } | ||
158 | |||
159 | /** | ||
160 | * @param User $user | ||
161 | * @return Account | ||
162 | */ | ||
163 | public function setUser(User $user) | ||
164 | { | ||
165 | $this->user = $user; | ||
166 | return $this; | ||
167 | } | ||
168 | |||
169 | /** | ||
170 | * @return Collection | ||
171 | */ | ||
172 | public function getFollowers() | ||
173 | { | ||
174 | return $this->followers; | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * @param Collection $followers | ||
179 | * @return Account | ||
180 | */ | ||
181 | public function setFollowers($followers) | ||
182 | { | ||
183 | $this->followers = $followers; | ||
184 | return $this; | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * @param Account $account | ||
189 | * @return Account | ||
190 | */ | ||
191 | public function addFollower(Account $account) | ||
192 | { | ||
193 | $this->followers->add($account); | ||
194 | return $this; | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * @return Collection | ||
199 | */ | ||
200 | public function getFollowing() | ||
201 | { | ||
202 | return $this->following; | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * @param Collection $following | ||
207 | * @return Account | ||
208 | */ | ||
209 | public function setFollowing(Collection $following) | ||
210 | { | ||
211 | $this->following = $following; | ||
212 | return $this; | ||
213 | } | ||
214 | |||
215 | /** | ||
216 | * @param Account $account | ||
217 | * @return Account | ||
218 | */ | ||
219 | public function addFollowing(Account $account) | ||
220 | { | ||
221 | $this->following->add($account); | ||
222 | return $this; | ||
223 | } | ||
224 | |||
225 | /** | ||
226 | * @return Collection | ||
227 | */ | ||
228 | public function getLiked() | ||
229 | { | ||
230 | return $this->liked; | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * @param Collection $liked | ||
235 | * @return Account | ||
236 | */ | ||
237 | public function setLiked(Collection $liked) | ||
238 | { | ||
239 | $this->liked = $liked; | ||
240 | return $this; | ||
241 | } | ||
242 | |||
243 | /** | ||
244 | * @param Entry $entry | ||
245 | * @return Account | ||
246 | */ | ||
247 | public function addLiked(Entry $entry) | ||
248 | { | ||
249 | $this->liked->add($entry); | ||
250 | return $this; | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * @return string | ||
255 | */ | ||
256 | public function getAvatar() | ||
257 | { | ||
258 | return $this->avatar; | ||
259 | } | ||
260 | |||
261 | /** | ||
262 | * @param string $avatar | ||
263 | * @return Account | ||
264 | */ | ||
265 | public function setAvatar($avatar) | ||
266 | { | ||
267 | $this->avatar = $avatar; | ||
268 | return $this; | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * @return string | ||
273 | */ | ||
274 | public function getBanner() | ||
275 | { | ||
276 | return $this->banner; | ||
277 | } | ||
278 | |||
279 | /** | ||
280 | * @param string $banner | ||
281 | * @return Account | ||
282 | */ | ||
283 | public function setBanner($banner) | ||
284 | { | ||
285 | $this->banner = $banner; | ||
286 | return $this; | ||
287 | } | ||
288 | |||
289 | /** | ||
290 | * @return string | ||
291 | */ | ||
292 | public function getDescription() | ||
293 | { | ||
294 | return $this->description; | ||
295 | } | ||
296 | |||
297 | /** | ||
298 | * @param string $description | ||
299 | * @return Account | ||
300 | */ | ||
301 | public function setDescription($description) | ||
302 | { | ||
303 | $this->description = $description; | ||
304 | return $this; | ||
305 | } | ||
306 | |||
307 | } | ||
diff --git a/src/Wallabag/FederationBundle/Entity/Instance.php b/src/Wallabag/FederationBundle/Entity/Instance.php new file mode 100644 index 00000000..ff8960cd --- /dev/null +++ b/src/Wallabag/FederationBundle/Entity/Instance.php | |||
@@ -0,0 +1,111 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\FederationBundle\Entity; | ||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; | ||
6 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | ||
7 | |||
8 | /** | ||
9 | * Account. | ||
10 | * | ||
11 | * @ORM\Entity | ||
12 | * @UniqueEntity(fields={"domain"}). | ||
13 | * @ORM\Table(name="`instance`") | ||
14 | */ | ||
15 | class Instance { | ||
16 | /** | ||
17 | * @var int | ||
18 | * | ||
19 | * @ORM\Column(name="id", type="integer") | ||
20 | * @ORM\Id | ||
21 | * @ORM\GeneratedValue(strategy="AUTO") | ||
22 | * | ||
23 | */ | ||
24 | private $id; | ||
25 | |||
26 | /** | ||
27 | * @var string | ||
28 | * | ||
29 | * @ORM\Column(name="domain", type="string") | ||
30 | */ | ||
31 | private $domain; | ||
32 | |||
33 | /** | ||
34 | * @var float | ||
35 | * | ||
36 | * @ORM\Column(name="score", type="float") | ||
37 | */ | ||
38 | private $score = 0; | ||
39 | |||
40 | /** | ||
41 | * @var array | ||
42 | * | ||
43 | * @ORM\OneToMany(targetEntity="Wallabag\FederationBundle\Entity\Account", mappedBy="server") | ||
44 | */ | ||
45 | private $users; | ||
46 | |||
47 | /** | ||
48 | * Instance constructor. | ||
49 | * @param string $domain | ||
50 | */ | ||
51 | public function __construct($domain) | ||
52 | { | ||
53 | $this->domain = $domain; | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * @return int | ||
58 | */ | ||
59 | public function getId() | ||
60 | { | ||
61 | return $this->id; | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * @return string | ||
66 | */ | ||
67 | public function getDomain() | ||
68 | { | ||
69 | return $this->domain; | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * @param string $domain | ||
74 | */ | ||
75 | public function setDomain($domain) | ||
76 | { | ||
77 | $this->domain = $domain; | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * @return float | ||
82 | */ | ||
83 | public function getScore() | ||
84 | { | ||
85 | return $this->score; | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * @param float $score | ||
90 | */ | ||
91 | public function setScore($score) | ||
92 | { | ||
93 | $this->score = $score; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * @return array | ||
98 | */ | ||
99 | public function getUsers() | ||
100 | { | ||
101 | return $this->users; | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * @param array $users | ||
106 | */ | ||
107 | public function setUsers($users) | ||
108 | { | ||
109 | $this->users = $users; | ||
110 | } | ||
111 | } | ||