|
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\OpenIDBundle\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
14
|
|
|
use LoginCidadao\CoreBundle\Model\PersonInterface; |
|
15
|
|
|
use LoginCidadao\OAuthBundle\Model\ClientInterface; |
|
16
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @ORM\Entity(repositoryClass="LoginCidadao\OpenIDBundle\Entity\SubjectIdentifierRepository") |
|
20
|
|
|
* @UniqueEntity({"client", "person"}) |
|
21
|
|
|
* @ORM\HasLifecycleCallbacks |
|
22
|
|
|
* @ORM\Table(name="subject_identifier") |
|
23
|
|
|
*/ |
|
24
|
|
|
class SubjectIdentifier |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @ORM\Id |
|
28
|
|
|
* @ORM\Column(type="integer") |
|
29
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $id; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var PersonInterface |
|
35
|
|
|
* @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\Person") |
|
36
|
|
|
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false) |
|
37
|
|
|
*/ |
|
38
|
|
|
private $person; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var ClientInterface |
|
42
|
|
|
* @ORM\ManyToOne(targetEntity="LoginCidadao\OAuthBundle\Entity\Client", inversedBy="authorizations") |
|
43
|
|
|
* @ORM\JoinColumn(name="client_id", referencedColumnName="id", nullable=false) |
|
44
|
|
|
*/ |
|
45
|
|
|
private $client; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var mixed |
|
49
|
|
|
* @ORM\Column(name="subject_identifier", type="string", nullable=false) |
|
50
|
|
|
*/ |
|
51
|
|
|
private $subjectIdentifier; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var \DateTime |
|
55
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
|
56
|
|
|
*/ |
|
57
|
|
|
private $createdAt; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var \DateTime |
|
61
|
|
|
* @ORM\Column(name="updated_at", type="datetime") |
|
62
|
|
|
*/ |
|
63
|
|
|
private $updatedAt; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return mixed |
|
|
|
|
|
|
67
|
|
|
*/ |
|
68
|
|
|
public function getPerson() |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->person; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param mixed $person |
|
|
|
|
|
|
75
|
|
|
* @return SubjectIdentifier |
|
76
|
|
|
*/ |
|
77
|
|
|
public function setPerson(PersonInterface $person) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->person = $person; |
|
80
|
|
|
|
|
81
|
|
|
return $this; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return ClientInterface |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getClient() |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->client; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param ClientInterface $client |
|
94
|
|
|
* @return SubjectIdentifier |
|
95
|
|
|
*/ |
|
96
|
|
|
public function setClient(ClientInterface $client) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->client = $client; |
|
99
|
|
|
|
|
100
|
|
|
return $this; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @return mixed |
|
105
|
|
|
*/ |
|
106
|
|
|
public function getSubjectIdentifier() |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->subjectIdentifier; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @param mixed $subjectIdentifier |
|
113
|
|
|
* @return SubjectIdentifier |
|
114
|
|
|
*/ |
|
115
|
|
|
public function setSubjectIdentifier($subjectIdentifier) |
|
116
|
|
|
{ |
|
117
|
|
|
$this->subjectIdentifier = $subjectIdentifier; |
|
118
|
|
|
|
|
119
|
|
|
return $this; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return mixed |
|
|
|
|
|
|
124
|
|
|
*/ |
|
125
|
|
|
public function getCreatedAt() |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->createdAt; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @ORM\PrePersist() |
|
132
|
|
|
* @param mixed $createdAt |
|
133
|
|
|
* @return SubjectIdentifier |
|
134
|
|
|
*/ |
|
135
|
|
|
public function setCreatedAt($createdAt = null) |
|
136
|
|
|
{ |
|
137
|
|
|
if ($createdAt instanceof \DateTime) { |
|
138
|
|
|
$this->createdAt = $createdAt; |
|
139
|
|
|
} else { |
|
140
|
|
|
$this->createdAt = \DateTime::createFromFormat('U', time()); |
|
|
|
|
|
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
return $this; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @return \DateTime |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getUpdatedAt() |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->updatedAt; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @ORM\PrePersist() |
|
156
|
|
|
* @ORM\PreUpdate() |
|
157
|
|
|
* @param \DateTime $updatedAt |
|
|
|
|
|
|
158
|
|
|
* @return SubjectIdentifier |
|
159
|
|
|
*/ |
|
160
|
|
|
public function setUpdatedAt($updatedAt = null) |
|
161
|
|
|
{ |
|
162
|
|
|
if ($updatedAt instanceof \DateTime) { |
|
163
|
|
|
$this->updatedAt = $updatedAt; |
|
164
|
|
|
} else { |
|
165
|
|
|
$this->updatedAt = \DateTime::createFromFormat('U', time()); |
|
|
|
|
|
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
return $this; |
|
169
|
|
|
} |
|
170
|
|
|
} |
|
171
|
|
|
|
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.