|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
/** |
|
4
|
|
|
* Contains class ContactList. |
|
5
|
|
|
* |
|
6
|
|
|
* PHP version 7.0+ |
|
7
|
|
|
* |
|
8
|
|
|
* LICENSE: |
|
9
|
|
|
* This file is part of Yet Another Php Eve Api Library also know as Yapeal |
|
10
|
|
|
* which can be used to access the Eve Online API data and place it into a |
|
11
|
|
|
* database. |
|
12
|
|
|
* Copyright (C) 2016-2017 Michael Cummings |
|
13
|
|
|
* |
|
14
|
|
|
* This program is free software: you can redistribute it and/or modify it |
|
15
|
|
|
* under the terms of the GNU Lesser General Public License as published by the |
|
16
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your |
|
17
|
|
|
* option) any later version. |
|
18
|
|
|
* |
|
19
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
20
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
21
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
|
22
|
|
|
* for more details. |
|
23
|
|
|
* |
|
24
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
25
|
|
|
* along with this program. If not, see |
|
26
|
|
|
* <http://spdx.org/licenses/LGPL-3.0.html>. |
|
27
|
|
|
* |
|
28
|
|
|
* You should be able to find a copy of this license in the COPYING-LESSER.md |
|
29
|
|
|
* file. A copy of the GNU GPL should also be available in the COPYING.md file. |
|
30
|
|
|
* |
|
31
|
|
|
* @copyright 2016-2017 Michael Cummings |
|
32
|
|
|
* @license LGPL-3.0+ |
|
33
|
|
|
* @author Michael Cummings <[email protected]> |
|
34
|
|
|
*/ |
|
35
|
|
|
namespace Yapeal\EveApi\Char; |
|
36
|
|
|
|
|
37
|
|
|
use Yapeal\Event\EveApiPreserverInterface; |
|
38
|
|
|
use Yapeal\Log\Logger; |
|
39
|
|
|
use Yapeal\Sql\PreserverTrait; |
|
40
|
|
|
use Yapeal\Xml\EveApiReadWriteInterface; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Class ContactList |
|
44
|
|
|
*/ |
|
45
|
|
|
class ContactList extends CharSection implements EveApiPreserverInterface |
|
46
|
|
|
{ |
|
47
|
|
|
use PreserverTrait; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Constructor |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->mask = 16; |
|
55
|
|
|
$this->preserveTos = [ |
|
56
|
|
|
'preserveToAllianceContactLabels', |
|
57
|
|
|
'preserveToAllianceContactList', |
|
58
|
|
|
'preserveToContactLabels', |
|
59
|
|
|
'preserveToContactList', |
|
60
|
|
|
'preserveToCorporateContactLabels', |
|
61
|
|
|
'preserveToCorporateContactList' |
|
62
|
|
|
]; |
|
63
|
|
|
} |
|
64
|
|
|
/** |
|
65
|
|
|
* @param EveApiReadWriteInterface $data |
|
66
|
|
|
* |
|
67
|
|
|
* @return self Fluent interface. |
|
68
|
|
|
* @throws \LogicException |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function preserveToAllianceContactLabels(EveApiReadWriteInterface $data) |
|
71
|
|
|
{ |
|
72
|
|
|
$tableName = 'charAllianceContactLabels'; |
|
73
|
|
|
$ownerID = $this->extractOwnerID($data->getEveApiArguments()); |
|
74
|
|
|
$sql = $this->getCsq() |
|
75
|
|
|
->getDeleteFromTableWithOwnerID($tableName, $ownerID); |
|
76
|
|
|
$this->getYem() |
|
77
|
|
|
->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, 'sql - ' . $sql); |
|
78
|
|
|
$this->getPdo() |
|
79
|
|
|
->exec($sql); |
|
80
|
|
|
$columnDefaults = [ |
|
81
|
|
|
'labelID' => null, |
|
82
|
|
|
'name' => '', |
|
83
|
|
|
'ownerID' => $ownerID |
|
84
|
|
|
]; |
|
85
|
|
|
$xPath = '//allianceContactLabels/row'; |
|
86
|
|
|
$elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath); |
|
87
|
|
|
$this->attributePreserveData($elements, $columnDefaults, $tableName); |
|
88
|
|
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
/** |
|
91
|
|
|
* @param EveApiReadWriteInterface $data |
|
92
|
|
|
* |
|
93
|
|
|
* @return self Fluent interface. |
|
94
|
|
|
* @throws \LogicException |
|
95
|
|
|
*/ |
|
96
|
|
|
protected function preserveToAllianceContactList(EveApiReadWriteInterface $data) |
|
97
|
|
|
{ |
|
98
|
|
|
$tableName = 'charAllianceContactList'; |
|
99
|
|
|
$ownerID = $this->extractOwnerID($data->getEveApiArguments()); |
|
100
|
|
|
$sql = $this->getCsq() |
|
101
|
|
|
->getDeleteFromTableWithOwnerID($tableName, $ownerID); |
|
102
|
|
|
$this->getYem() |
|
103
|
|
|
->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, 'sql - ' . $sql); |
|
104
|
|
|
$this->getPdo() |
|
105
|
|
|
->exec($sql); |
|
106
|
|
|
$columnDefaults = [ |
|
107
|
|
|
'contactID' => null, |
|
108
|
|
|
'contactName' => '', |
|
109
|
|
|
'contactTypeID' => null, |
|
110
|
|
|
'labelMask' => null, |
|
111
|
|
|
'ownerID' => $ownerID, |
|
112
|
|
|
'standing' => null |
|
113
|
|
|
]; |
|
114
|
|
|
$xPath = '//allianceContactList/row'; |
|
115
|
|
|
$elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath); |
|
116
|
|
|
$this->attributePreserveData($elements, $columnDefaults, $tableName); |
|
117
|
|
|
return $this; |
|
118
|
|
|
} |
|
119
|
|
|
/** |
|
120
|
|
|
* @param EveApiReadWriteInterface $data |
|
121
|
|
|
* |
|
122
|
|
|
* @return self Fluent interface. |
|
123
|
|
|
* @throws \LogicException |
|
124
|
|
|
*/ |
|
125
|
|
|
protected function preserveToContactLabels(EveApiReadWriteInterface $data) |
|
126
|
|
|
{ |
|
127
|
|
|
$tableName = 'charContactLabels'; |
|
128
|
|
|
$ownerID = $this->extractOwnerID($data->getEveApiArguments()); |
|
129
|
|
|
$sql = $this->getCsq() |
|
130
|
|
|
->getDeleteFromTableWithOwnerID($tableName, $ownerID); |
|
131
|
|
|
$this->getYem() |
|
132
|
|
|
->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, 'sql - ' . $sql); |
|
133
|
|
|
$this->getPdo() |
|
134
|
|
|
->exec($sql); |
|
135
|
|
|
$columnDefaults = [ |
|
136
|
|
|
'labelID' => null, |
|
137
|
|
|
'name' => '', |
|
138
|
|
|
'ownerID' => $ownerID |
|
139
|
|
|
]; |
|
140
|
|
|
$xPath = '//contactLabels/row'; |
|
141
|
|
|
$elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath); |
|
142
|
|
|
$this->attributePreserveData($elements, $columnDefaults, $tableName); |
|
143
|
|
|
return $this; |
|
144
|
|
|
} |
|
145
|
|
|
/** |
|
146
|
|
|
* @param EveApiReadWriteInterface $data |
|
147
|
|
|
* |
|
148
|
|
|
* @return self Fluent interface. |
|
149
|
|
|
* @throws \LogicException |
|
150
|
|
|
*/ |
|
151
|
|
|
protected function preserveToContactList(EveApiReadWriteInterface $data) |
|
152
|
|
|
{ |
|
153
|
|
|
$tableName = 'charContactList'; |
|
154
|
|
|
$ownerID = $this->extractOwnerID($data->getEveApiArguments()); |
|
155
|
|
|
$sql = $this->getCsq() |
|
156
|
|
|
->getDeleteFromTableWithOwnerID($tableName, $ownerID); |
|
157
|
|
|
$this->getYem() |
|
158
|
|
|
->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, 'sql - ' . $sql); |
|
159
|
|
|
$this->getPdo() |
|
160
|
|
|
->exec($sql); |
|
161
|
|
|
$columnDefaults = [ |
|
162
|
|
|
'contactID' => null, |
|
163
|
|
|
'contactName' => '', |
|
164
|
|
|
'contactTypeID' => null, |
|
165
|
|
|
'inWatchlist' => null, |
|
166
|
|
|
'labelMask' => null, |
|
167
|
|
|
'ownerID' => $ownerID, |
|
168
|
|
|
'standing' => null |
|
169
|
|
|
]; |
|
170
|
|
|
$xPath = '//contactList/row'; |
|
171
|
|
|
$elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath); |
|
172
|
|
|
$this->attributePreserveData($elements, $columnDefaults, $tableName); |
|
173
|
|
|
return $this; |
|
174
|
|
|
} |
|
175
|
|
|
/** |
|
176
|
|
|
* @param EveApiReadWriteInterface $data |
|
177
|
|
|
* |
|
178
|
|
|
* @return self Fluent interface. |
|
179
|
|
|
* @throws \LogicException |
|
180
|
|
|
*/ |
|
181
|
|
|
protected function preserveToCorporateContactLabels(EveApiReadWriteInterface $data) |
|
182
|
|
|
{ |
|
183
|
|
|
$tableName = 'charCorporateContactLabels'; |
|
184
|
|
|
$ownerID = $this->extractOwnerID($data->getEveApiArguments()); |
|
185
|
|
|
$sql = $this->getCsq() |
|
186
|
|
|
->getDeleteFromTableWithOwnerID($tableName, $ownerID); |
|
187
|
|
|
$this->getYem() |
|
188
|
|
|
->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, 'sql - ' . $sql); |
|
189
|
|
|
$this->getPdo() |
|
190
|
|
|
->exec($sql); |
|
191
|
|
|
$columnDefaults = [ |
|
192
|
|
|
'labelID' => null, |
|
193
|
|
|
'name' => '', |
|
194
|
|
|
'ownerID' => $ownerID |
|
195
|
|
|
]; |
|
196
|
|
|
$xPath = '//corporateContactLabels/row'; |
|
197
|
|
|
$elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath); |
|
198
|
|
|
$this->attributePreserveData($elements, $columnDefaults, $tableName); |
|
199
|
|
|
return $this; |
|
200
|
|
|
} |
|
201
|
|
|
/** |
|
202
|
|
|
* @param EveApiReadWriteInterface $data |
|
203
|
|
|
* |
|
204
|
|
|
* @return self Fluent interface. |
|
205
|
|
|
* @throws \LogicException |
|
206
|
|
|
*/ |
|
207
|
|
|
protected function preserveToCorporateContactList(EveApiReadWriteInterface $data) |
|
208
|
|
|
{ |
|
209
|
|
|
$tableName = 'charCorporateContactList'; |
|
210
|
|
|
$ownerID = $this->extractOwnerID($data->getEveApiArguments()); |
|
211
|
|
|
$sql = $this->getCsq() |
|
212
|
|
|
->getDeleteFromTableWithOwnerID($tableName, $ownerID); |
|
213
|
|
|
$this->getYem() |
|
214
|
|
|
->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, 'sql - ' . $sql); |
|
215
|
|
|
$this->getPdo() |
|
216
|
|
|
->exec($sql); |
|
217
|
|
|
$columnDefaults = [ |
|
218
|
|
|
'contactID' => null, |
|
219
|
|
|
'contactName' => '', |
|
220
|
|
|
'contactTypeID' => null, |
|
221
|
|
|
'labelMask' => null, |
|
222
|
|
|
'ownerID' => $ownerID, |
|
223
|
|
|
'standing' => null |
|
224
|
|
|
]; |
|
225
|
|
|
$xPath = '//corporateContactList/row'; |
|
226
|
|
|
$elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath); |
|
227
|
|
|
$this->attributePreserveData($elements, $columnDefaults, $tableName); |
|
228
|
|
|
return $this; |
|
229
|
|
|
} |
|
230
|
|
|
} |
|
231
|
|
|
|