|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace LoginCidadao\OAuthBundle\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken; |
|
14
|
|
|
use JMS\Serializer\Annotation as JMS; |
|
15
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @ORM\Entity(repositoryClass="LoginCidadao\OAuthBundle\Entity\AccessTokenRepository") |
|
19
|
|
|
* @ORM\Table(name="access_token") |
|
20
|
|
|
* @ORM\HasLifecycleCallbacks |
|
21
|
|
|
* @ORM\AttributeOverrides({ |
|
22
|
|
|
* @ORM\AttributeOverride(name="scope", |
|
23
|
|
|
* column=@ORM\Column( |
|
24
|
|
|
* name = "scope", |
|
25
|
|
|
* type = "string", |
|
26
|
|
|
* length = 1000, |
|
27
|
|
|
* nullable = true |
|
28
|
|
|
* ) |
|
29
|
|
|
* ) |
|
30
|
|
|
* }) |
|
31
|
|
|
*/ |
|
32
|
|
|
class AccessToken extends BaseAccessToken |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @ORM\Id |
|
36
|
|
|
* @ORM\Column(type="integer") |
|
37
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $id; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @ORM\ManyToOne(targetEntity="Client") |
|
43
|
|
|
* @ORM\JoinColumn(nullable=false) |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $client; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\Person") |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $user; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @ORM\Column(name="id_token", type="text", nullable=true) |
|
54
|
|
|
* @var string |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $idToken; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @ORM\Column(name="created_at", type="datetime", nullable=true) |
|
60
|
|
|
* @JMS\Since("1.14") |
|
61
|
|
|
* @var \DateTime |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $createdAt; |
|
64
|
|
|
|
|
65
|
|
|
public function setExpired() |
|
66
|
|
|
{ |
|
67
|
|
|
$now = new \DateTime(); |
|
68
|
|
|
$this->setExpiresAt($now->getTimestamp()); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function getIdToken() |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->idToken; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function setIdToken($idToken) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->idToken = $idToken; |
|
79
|
|
|
|
|
80
|
|
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return \DateTime |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getCreatedAt() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->createdAt; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @ORM\PrePersist |
|
93
|
|
|
*/ |
|
94
|
|
|
public function setCreatedAtValue() |
|
95
|
|
|
{ |
|
96
|
|
|
if (!($this->getCreatedAt() instanceof \DateTime)) { |
|
97
|
|
|
$this->createdAt = new \DateTime(); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|