aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/GroupBundle/Entity/Invitation.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/GroupBundle/Entity/Invitation.php')
-rw-r--r--src/Wallabag/GroupBundle/Entity/Invitation.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/Wallabag/GroupBundle/Entity/Invitation.php b/src/Wallabag/GroupBundle/Entity/Invitation.php
new file mode 100644
index 00000000..6946bede
--- /dev/null
+++ b/src/Wallabag/GroupBundle/Entity/Invitation.php
@@ -0,0 +1,73 @@
1<?php
2
3namespace Wallabag\GroupBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6
7/**
8 * @ORM\Entity
9 */
10class Invitation
11{
12 /**
13 * @ORM\Id
14 * @ORM\Column(type="string", length=6)
15 */
16 protected $code;
17
18 /**
19 * @var \DateTime
20 * @ORM\Column(type="datetime")
21 */
22 protected $date;
23
24 /**
25 * @ORM\OneToOne(targetEntity="UserGroup", mappedBy="invitation")
26 */
27 protected $userGroup;
28
29 public function __construct(UserGroup $userGroup)
30 {
31 // generate identifier only once, here a 6 characters length code
32 $this->code = substr(md5(uniqid(rand(), true)), 0, 6);
33 $this->date = new \DateTime();
34 $this->userGroup = $userGroup;
35 }
36
37 public function getCode()
38 {
39 return $this->code;
40 }
41
42 /**
43 * @return \DateTime
44 */
45 public function getDate(): \DateTime
46 {
47 return $this->date;
48 }
49
50 /**
51 * @param \DateTime $date
52 */
53 public function setDate(\DateTime $date)
54 {
55 $this->date = $date;
56 }
57
58 /**
59 * @return mixed
60 */
61 public function getUserGroup(): UserGroup
62 {
63 return $this->userGroup;
64 }
65
66 /**
67 * @param mixed $userGroup
68 */
69 public function setUserGroup(UserGroup $userGroup)
70 {
71 $this->userGroup = $userGroup;
72 }
73}