1
|
|
|
<?php |
2
|
|
|
namespace PlaygroundGame\Entity; |
3
|
|
|
|
4
|
|
|
use Doctrine\ORM\Mapping as ORM; |
5
|
|
|
use Doctrine\ORM\Mapping\HasLifecycleCallbacks; |
6
|
|
|
use Doctrine\ORM\Mapping\PrePersist; |
7
|
|
|
use Doctrine\ORM\Mapping\PreUpdate; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @ORM\Entity @HasLifecycleCallbacks |
11
|
|
|
* @ORM\Table(name="game_invitation") |
12
|
|
|
*/ |
13
|
|
|
class Invitation implements \JsonSerializable |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @ORM\ManyToOne(targetEntity="Game", cascade={"persist","remove"}) |
17
|
|
|
* @ORM\JoinColumn(name="game_id", referencedColumnName="id", onDelete="CASCADE") |
18
|
|
|
**/ |
19
|
|
|
protected $game; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
* @ORM\Id |
24
|
|
|
* @ORM\Column(name="request_key", type="string", length=32, nullable=false) |
25
|
|
|
*/ |
26
|
|
|
protected $requestKey; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @ORM\ManyToOne(targetEntity="PlaygroundUser\Entity\User") |
30
|
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="user_id") |
31
|
|
|
**/ |
32
|
|
|
protected $user; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
36
|
|
|
*/ |
37
|
|
|
protected $createdAt; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @ORM\Column(name="updated_at", type="datetime") |
41
|
|
|
*/ |
42
|
|
|
protected $updatedAt; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @PrePersist |
46
|
|
|
*/ |
47
|
|
|
public function createChrono() |
48
|
|
|
{ |
49
|
|
|
$this->createdAt = new \DateTime("now"); |
50
|
|
|
$this->updatedAt = new \DateTime("now"); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @PreUpdate |
55
|
|
|
*/ |
56
|
|
|
public function updateChrono() |
57
|
|
|
{ |
58
|
|
|
$this->updatedAt = new \DateTime("now"); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function setRequestKey($key) |
62
|
|
|
{ |
63
|
|
|
$this->requestKey = $key; |
64
|
|
|
|
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getRequestKey() |
69
|
|
|
{ |
70
|
|
|
return $this->requestKey; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function setUser($user) |
74
|
|
|
{ |
75
|
|
|
$this->user = $user; |
76
|
|
|
|
77
|
|
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getUser() |
81
|
|
|
{ |
82
|
|
|
return $this->user; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return the unknown_type |
87
|
|
|
*/ |
88
|
|
|
public function getGame() |
89
|
|
|
{ |
90
|
|
|
return $this->game; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param unknown_type $game |
95
|
|
|
*/ |
96
|
|
|
public function setGame($game) |
97
|
|
|
{ |
98
|
|
|
$this->game = $game; |
99
|
|
|
|
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Convert the object to an array. |
105
|
|
|
* |
106
|
|
|
* @return array |
107
|
|
|
*/ |
108
|
|
|
public function getArrayCopy() |
109
|
|
|
{ |
110
|
|
|
$obj_vars = get_object_vars($this); |
111
|
|
|
|
112
|
|
|
return $obj_vars; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Convert the object to json. |
117
|
|
|
* |
118
|
|
|
* @return array |
119
|
|
|
*/ |
120
|
|
|
public function jsonSerialize() |
121
|
|
|
{ |
122
|
|
|
return $this->getArrayCopy(); |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|