1
|
|
|
<?php |
2
|
|
|
namespace Tarioch\EveapiFetcherBundle\Component\EveApi\Char; |
3
|
|
|
|
4
|
|
|
use JMS\DiExtraBundle\Annotation as DI; |
5
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\ApiCall; |
6
|
|
|
use Pheal\Pheal; |
7
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\ApiKey; |
8
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharContact; |
9
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharCorporateContact; |
10
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharAllianceContact; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @DI\Service("tarioch.eveapi.char.ContactList") |
14
|
|
|
*/ |
15
|
|
|
class ContactUpdater extends AbstractCharUpdater |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @inheritdoc |
20
|
|
|
*/ |
21
|
|
|
public function update(ApiCall $call, ApiKey $key, Pheal $pheal) |
22
|
|
|
{ |
23
|
|
|
$charId = $call->getOwner()->getCharacterId(); |
24
|
|
|
|
25
|
|
|
$query = 'delete from TariochEveapiFetcherBundle:CharContact c where c.ownerId=:ownerId'; |
26
|
|
|
$this->entityManager->createQuery($query) |
27
|
|
|
->setParameter('ownerId', $charId) |
28
|
|
|
->execute(); |
29
|
|
|
|
30
|
|
|
$query = 'delete from TariochEveapiFetcherBundle:CharCorporateContact c where c.ownerId=:ownerId'; |
31
|
|
|
$this->entityManager->createQuery($query) |
32
|
|
|
->setParameter('ownerId', $charId) |
33
|
|
|
->execute(); |
34
|
|
|
|
35
|
|
|
$query = 'delete from TariochEveapiFetcherBundle:CharAllianceContact c where c.ownerId=:ownerId'; |
36
|
|
|
$this->entityManager->createQuery($query) |
37
|
|
|
->setParameter('ownerId', $charId) |
38
|
|
|
->execute(); |
39
|
|
|
|
40
|
|
|
$api = $pheal->charScope->ContactList(array( |
41
|
|
|
'characterID' => $charId |
42
|
|
|
)); |
43
|
|
|
|
44
|
|
|
foreach ($api->contactList as $contactApi) { |
45
|
|
|
$entity = new CharContact($charId, $contactApi->contactID); |
46
|
|
|
$entity->setContactName($contactApi->contactName); |
47
|
|
|
$entity->setStanding($contactApi->standing); |
48
|
|
|
$this->entityManager->persist($entity); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
foreach ($api->corporateContactList as $contactApi) { |
52
|
|
|
$entity = new CharCorporateContact($charId, $contactApi->contactID); |
53
|
|
|
$entity->setContactName($contactApi->contactName); |
54
|
|
|
$entity->setStanding($contactApi->standing); |
55
|
|
|
$this->entityManager->persist($entity); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
foreach ($api->allianceContactList as $contactApi) { |
59
|
|
|
$entity = new CharAllianceContact($charId, $contactApi->contactID); |
60
|
|
|
$entity->setContactName($contactApi->contactName); |
61
|
|
|
$entity->setStanding($contactApi->standing); |
62
|
|
|
$this->entityManager->persist($entity); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
return $api->cached_until; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|