Esempio n. 1
0
 public function getMembers(Corporation $corporation)
 {
     $apiKey = $this->getApiKey($corporation);
     $client = $this->getClient($apiKey);
     $members = $client->MemberTracking()->members;
     $repo = $this->doctrine->getRepository('AppBundle:CorporationMember');
     $existing_members = $repo->findBy(['corporation' => $corporation]);
     $ids = [];
     foreach ($existing_members as $m) {
         $ids[(int) $m->getCharacterId()] = $m;
     }
     foreach ($members as $m) {
         $intId = (int) $m->characterID;
         if (!isset($ids[$intId])) {
             $mem = new CorporationMember();
             $mem->setCharacterId($m->characterID)->setCharacterName($m->name)->setStartTime(new \DateTime($m->startDateTime));
             /*
              * @TODO you forgot the homebase..
              */
             $corporation->addCorporationMember($mem);
         } else {
             /*
              * @TODO just lost their history
              */
             if ($ids[$intId]->getDisbandedAt() !== null) {
                 $ids[$intId]->setDisbandedAt(null)->setStartTime(new \Datetime($m->startDateTime));
             }
             unset($ids[$intId]);
         }
     }
     // any that were left over are not in our list anymore...
     foreach ($ids as $deleted_member) {
         $deleted_member->setDisbandedAt(new \DateTime());
     }
 }
 public function findRelatedKeyByMember(CorporationMember $member)
 {
     return $this->createQueryBuilder('api')->leftJoin('api.characters', 'c')->where('c.eve_id = :char_id')->andWhere('api.type IN ( :api_types )')->setParameters(['char_id' => $member->getCharacterId(), 'api_types' => ['Character', 'Account']])->getQuery()->getOneOrNullResult();
 }