1
|
|
|
<?php |
2
|
|
|
namespace Tarioch\EveapiFetcherBundle\Component\EveApi\Corp; |
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\CorpBlueprint; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @DI\Service("tarioch.eveapi.corp.Blueprints") |
12
|
|
|
*/ |
13
|
|
|
class BlueprintUpdater extends AbstractCorpUpdater |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @inheritdoc |
17
|
|
|
*/ |
18
|
|
|
public function update(ApiCall $call, ApiKey $key, Pheal $pheal) |
19
|
|
|
{ |
20
|
|
|
$owner = $call->getOwner(); |
21
|
|
|
$corpId = $owner->getCorporationId(); |
22
|
|
|
$api = $pheal->corpScope->Blueprints(); |
23
|
|
|
|
24
|
|
|
$this->entityManager |
25
|
|
|
->createQuery('delete from TariochEveapiFetcherBundle:CorpBlueprint c where c.ownerId=:ownerId') |
26
|
|
|
->setParameter('ownerId', $corpId) |
27
|
|
|
->execute(); |
28
|
|
|
|
29
|
|
|
$this->addBlueprints($api->blueprints, $corpId); |
30
|
|
|
|
31
|
|
|
return $api->cached_until; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
private function addBlueprints($blueprints, $corpId) |
35
|
|
|
{ |
36
|
|
|
foreach ($blueprints as $blueprint) { |
37
|
|
|
$entity = new CorpBlueprint(); |
38
|
|
|
$entity->setOwnerId($corpId); |
39
|
|
|
$entity->setLocationId($blueprint->locationID); |
40
|
|
|
$entity->setItemId($blueprint->itemID); |
41
|
|
|
$entity->setTypeId($blueprint->typeID); |
42
|
|
|
$entity->setTypeName($blueprint->typeName); |
43
|
|
|
$entity->setQuantity($blueprint->quantity); |
44
|
|
|
$entity->setFlag($blueprint->flagID); |
45
|
|
|
$entity->setRuns($blueprint->runs); |
46
|
|
|
$entity->setTimeEfficiency($blueprint->timeEfficiency); |
47
|
|
|
$entity->setMaterialEfficiency($blueprint->materialEfficiency); |
48
|
|
|
|
49
|
|
|
$this->entityManager->persist($entity); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|