Exemplo n.º 1
0
 protected function get($type)
 {
     $module = new CountryModule($this->client);
     $em = $this->getEntityManager();
     $countries = $em->getRepository('Erpk\\Common\\Entity\\Country');
     $code = $this->getParameter('code');
     if (preg_match('/^[0-9]+$/', $code)) {
         $country = $countries->findOneById((int) $code);
     } else {
         $country = $countries->findOneByCode($code);
     }
     if ($country instanceof Country) {
         $data = $module->{'get' . $type}($country);
         switch ($type) {
             case 'Economy':
                 $data['embargoes']['@nodeName'] = 'embargo';
                 break;
             case 'Society':
                 $data['regions']['@nodeName'] = 'region';
                 break;
         }
         $vm = new ViewModel($data);
         $vm->setRootNodeName('country');
     } else {
         $vm = ViewModel::error('CountryNotFoundException', 500);
     }
     return $vm;
 }
Exemplo n.º 2
0
 public function getParty()
 {
     $module = new PoliticsModule($this->client);
     $data = $module->getParty($this->getParameter('id'));
     $vm = new ViewModel($data);
     $vm->setRootNodeName('party');
     return $vm;
 }
Exemplo n.º 3
0
 public function search()
 {
     $module = new CitizenModule($this->client);
     $data = $module->search($this->getParameter('query'), $this->getParameter('page'));
     $data['@nodeName'] = 'citizen';
     $vm = new ViewModel($data);
     $vm->setRootNodeName('results');
     return $vm;
 }
Exemplo n.º 4
0
 public function active()
 {
     $module = new MilitaryModule($this->client);
     $data = $module->getActiveCampaigns();
     $data = $data['all'];
     $data['@nodeName'] = 'battle';
     $vm = new ViewModel($data);
     $vm->setRootNodeName('battles');
     return $vm;
 }
Exemplo n.º 5
0
 public function get()
 {
     $module = new JobMarketModule($this->client);
     $em = $this->getEntityManager();
     $countries = $em->getRepository('Erpk\\Common\\Entity\\Country');
     $country = $countries->findOneByCode($this->getParameter('code'));
     $data = $module->scan($country, $this->getParameter('page'));
     $data['@nodeName'] = 'offer';
     $vm = new ViewModel($data);
     $vm->setRootNodeName('offers');
     return $vm;
 }
Exemplo n.º 6
0
 public function getRegiment()
 {
     $module = new MilitaryModule($this->client);
     $data = $module->getRegiment($this->getParameter('unit'), $this->getParameter('regiment'));
     foreach ($data as &$s) {
         $s['location'] = $s['location']->toArray();
     }
     $data['@nodeName'] = 'member';
     $vm = new ViewModel($data);
     $vm->setRootNodeName('members');
     return $vm;
 }
Exemplo n.º 7
0
 public function get()
 {
     switch ($this->getParameter('mode')) {
         case 'cc':
             $buy = ExchangeModule::CURRENCY;
             break;
         case 'gold':
         default:
             $buy = ExchangeModule::GOLD;
             break;
     }
     $module = new ExchangeModule($this->client);
     $offers = $module->scan($buy, $this->getParameter('page'));
     $data = array('paginator' => $offers->getPaginator()->toArray(), 'offers' => $offers->getArrayCopy());
     $data['offers']['@nodeName'] = 'offer';
     $vm = new ViewModel($data);
     $vm->setRootNodeName('offers');
     return $vm;
 }