1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\Models\CMS; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Types\Type; |
8
|
|
|
use Doctrine\ORM\Annotation as ORM; |
9
|
|
|
use Doctrine\ORM\Mapping; |
10
|
|
|
use Doctrine\Tests\Models\CMS\CmsAddressListener; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* CmsAddress |
14
|
|
|
* |
15
|
|
|
* @author Roman S. Borschel |
16
|
|
|
* |
17
|
|
|
* @ORM\Entity |
18
|
|
|
* @ORM\Table(name="cms_addresses") |
19
|
|
|
* |
20
|
|
|
* @ORM\NamedNativeQueries({ |
21
|
|
|
* @ORM\NamedNativeQuery( |
22
|
|
|
* name = "find-all", |
23
|
|
|
* resultSetMapping = "mapping-find-all", |
24
|
|
|
* query = "SELECT id, country, city FROM cms_addresses" |
25
|
|
|
* ), |
26
|
|
|
* @ORM\NamedNativeQuery( |
27
|
|
|
* name = "find-by-id", |
28
|
|
|
* resultClass = "CmsAddress", |
29
|
|
|
* query = "SELECT * FROM cms_addresses WHERE id = ?" |
30
|
|
|
* ), |
31
|
|
|
* @ORM\NamedNativeQuery( |
32
|
|
|
* name = "count", |
33
|
|
|
* resultSetMapping= "mapping-count", |
34
|
|
|
* query = "SELECT COUNT(*) AS count FROM cms_addresses" |
35
|
|
|
* ) |
36
|
|
|
* }) |
37
|
|
|
* |
38
|
|
|
* @ORM\SqlResultSetMappings({ |
39
|
|
|
* @ORM\SqlResultSetMapping( |
40
|
|
|
* name = "mapping-find-all", |
41
|
|
|
* entities= { |
42
|
|
|
* @ORM\EntityResult( |
43
|
|
|
* entityClass = "CmsAddress", |
44
|
|
|
* fields = { |
45
|
|
|
* @ORM\FieldResult(name = "id", column="id"), |
46
|
|
|
* @ORM\FieldResult(name = "city", column="city"), |
47
|
|
|
* @ORM\FieldResult(name = "country", column="country") |
48
|
|
|
* } |
49
|
|
|
* ) |
50
|
|
|
* } |
51
|
|
|
* ), |
52
|
|
|
* @ORM\SqlResultSetMapping( |
53
|
|
|
* name = "mapping-without-fields", |
54
|
|
|
* entities= { |
55
|
|
|
* @ORM\EntityResult( |
56
|
|
|
* entityClass = "__CLASS__" |
57
|
|
|
* ) |
58
|
|
|
* } |
59
|
|
|
* ), |
60
|
|
|
* @ORM\SqlResultSetMapping( |
61
|
|
|
* name = "mapping-count", |
62
|
|
|
* columns = { |
63
|
|
|
* @ORM\ColumnResult( |
64
|
|
|
* name = "count" |
65
|
|
|
* ) |
66
|
|
|
* } |
67
|
|
|
* ) |
68
|
|
|
* }) |
69
|
|
|
* |
70
|
|
|
* @ORM\EntityListeners({"CmsAddressListener"}) |
71
|
|
|
*/ |
72
|
|
|
class CmsAddress |
73
|
|
|
{ |
74
|
|
|
/** |
75
|
|
|
* @ORM\Column(type="integer") |
76
|
|
|
* @ORM\Id @ORM\GeneratedValue |
77
|
|
|
*/ |
78
|
|
|
public $id; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @ORM\Column(length=50) |
82
|
|
|
*/ |
83
|
|
|
public $country; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @ORM\Column(length=50) |
87
|
|
|
*/ |
88
|
|
|
public $zip; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @ORM\Column(length=50) |
92
|
|
|
*/ |
93
|
|
|
public $city; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Testfield for Schema Updating Tests. |
97
|
|
|
*/ |
98
|
|
|
public $street; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @ORM\OneToOne(targetEntity="CmsUser", inversedBy="address") |
102
|
|
|
* @ORM\JoinColumn(referencedColumnName="id") |
103
|
|
|
*/ |
104
|
|
|
public $user; |
105
|
|
|
|
106
|
|
|
public function getId() { |
107
|
|
|
return $this->id; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getUser() { |
111
|
|
|
return $this->user; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function getCountry() { |
115
|
|
|
return $this->country; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function getZipCode() { |
119
|
|
|
return $this->zip; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getCity() { |
123
|
|
|
return $this->city; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function setUser(CmsUser $user) { |
127
|
|
|
if ($this->user !== $user) { |
128
|
|
|
$this->user = $user; |
129
|
|
|
$user->setAddress($this); |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|