1 | <?php |
||
2 | |||
3 | /* |
||
4 | * @copyright 2014 Mautic Contributors. All rights reserved |
||
5 | * @author Mautic |
||
6 | * |
||
7 | * @link http://mautic.org |
||
8 | * |
||
9 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
10 | */ |
||
11 | |||
12 | namespace Mautic\EmailBundle\Entity; |
||
13 | |||
14 | use Doctrine\ORM\Mapping as ORM; |
||
15 | use Mautic\ApiBundle\Serializer\Driver\ApiMetadataDriver; |
||
16 | use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder; |
||
17 | use Mautic\CoreBundle\Entity\IpAddress; |
||
18 | use Mautic\LeadBundle\Entity\LeadDevice; |
||
19 | |||
20 | /** |
||
21 | * Class StatDevice. |
||
22 | */ |
||
23 | class StatDevice |
||
24 | { |
||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | private $id; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | private $stat; |
||
34 | |||
35 | /** |
||
36 | * @var \Mautic\LeadBundle\Entity\LeadDevice |
||
37 | */ |
||
38 | private $device; |
||
39 | |||
40 | /** |
||
41 | * @var \Mautic\CoreBundle\Entity\IpAddress |
||
42 | */ |
||
43 | private $ipAddress; |
||
44 | |||
45 | /** |
||
46 | * @var \DateTime |
||
47 | */ |
||
48 | private $dateOpened; |
||
49 | |||
50 | public static function loadMetadata(ORM\ClassMetadata $metadata) |
||
51 | { |
||
52 | $builder = new ClassMetadataBuilder($metadata); |
||
53 | |||
54 | $builder->setTable('email_stats_devices') |
||
55 | ->setCustomRepositoryClass('Mautic\EmailBundle\Entity\StatDeviceRepository') |
||
56 | ->addIndex(['date_opened'], 'date_opened_search'); |
||
57 | |||
58 | $builder->addBigIntIdField(); |
||
59 | |||
60 | $builder->createManyToOne('device', 'Mautic\LeadBundle\Entity\LeadDevice') |
||
61 | ->addJoinColumn('device_id', 'id', true, false, 'CASCADE') |
||
62 | ->build(); |
||
63 | |||
64 | $builder->createManyToOne('stat', 'Stat') |
||
65 | ->addJoinColumn('stat_id', 'id', true, false, 'CASCADE') |
||
66 | ->build(); |
||
67 | |||
68 | $builder->addIpAddress(true); |
||
69 | |||
70 | $builder->createField('dateOpened', 'datetime') |
||
71 | ->columnName('date_opened') |
||
72 | ->build(); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Prepares the metadata for API usage. |
||
77 | * |
||
78 | * @param $metadata |
||
79 | */ |
||
80 | public static function loadApiMetadata(ApiMetadataDriver $metadata) |
||
81 | { |
||
82 | $metadata->setGroupPrefix('stat') |
||
83 | ->addProperties( |
||
84 | [ |
||
85 | 'id', |
||
86 | 'device', |
||
87 | 'ipAddress', |
||
88 | 'stat', |
||
89 | ] |
||
90 | ) |
||
91 | ->build(); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @return mixed |
||
96 | */ |
||
97 | public function getId() |
||
98 | { |
||
99 | return $this->id; |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @return IpAddress |
||
104 | */ |
||
105 | public function getIpAddress() |
||
106 | { |
||
107 | return $this->ipAddress; |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * @param mixed $ip |
||
112 | */ |
||
113 | public function setIpAddress(IpAddress $ip) |
||
114 | { |
||
115 | $this->ipAddress = $ip; |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * @return Stat |
||
120 | */ |
||
121 | public function getStat() |
||
122 | { |
||
123 | return $this->stat; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @param Stat |
||
128 | */ |
||
129 | public function setStat(Stat $stat) |
||
130 | { |
||
131 | $this->stat = $stat; |
||
0 ignored issues
–
show
It seems like
$stat of type Mautic\EmailBundle\Entity\Stat is incompatible with the declared type array of property $stat .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
Loading history...
|
|||
132 | } |
||
133 | |||
134 | /** |
||
135 | * @return mixed |
||
136 | */ |
||
137 | public function getDateOpened() |
||
138 | { |
||
139 | return $this->dateOpened; |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @param mixed $dateOpened |
||
144 | */ |
||
145 | public function setDateOpened($dateOpened) |
||
146 | { |
||
147 | $this->dateOpened = $dateOpened; |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * @return mixed |
||
152 | */ |
||
153 | public function getDevice() |
||
154 | { |
||
155 | return $this->device; |
||
156 | } |
||
157 | |||
158 | /** |
||
159 | * @param mixed $device |
||
160 | */ |
||
161 | public function setDevice(LeadDevice $device) |
||
162 | { |
||
163 | $this->device = $device; |
||
164 | } |
||
165 | } |
||
166 |