Exemple #1
0
 /**
  * @Route("/items/{id}/details", name="item_details")
  * @Template()
  * @ActionCache(maxage=5184000)
  */
 public function detailsAction($id)
 {
     $repo = $this->get('lolapi.manager.item');
     $item = $repo->findOneById($id);
     $stats = new ItemStats($item, $this->get('service_container'));
     try {
         $next = $this->get('lolapi')->setRegion('na')->call('static_data', 'item_details', ['id' => $item->getDistantId()], ['version' => '5.14.1', 'itemData' => "all"]);
         $prev = $this->get('lolapi')->setRegion('na')->call('static_data', 'item_details', ['id' => $item->getDistantId()], ['version' => '5.11.1', 'itemData' => "all"]);
     } catch (\Exception $e) {
         if (!isset($next)) {
             $next = false;
         }
         if (!isset($prev)) {
             $prev = false;
         }
     }
     return ['champions' => $stats->getMainChampions(), 'item' => $item, 'stats' => $stats, 'data' => ['511' => $prev, '514' => $next]];
 }
 public function updateItems()
 {
     $container = $this->getContainer();
     $manager = $container->get('lolapi.manager.item');
     $items = $manager->findAll();
     foreach ($items as $item) {
         $stats = new ItemStats($item, $container);
         $stats->setRefresh(true);
         foreach (self::$versions as $version) {
             $stats->getUsage($version);
             foreach ($stats->getMainChampions() as $champion) {
                 $stats->getChampionUsage($version, $champion);
                 $stats->getChampionWinrate($version, $champion);
             }
         }
     }
 }