コード例 #1
0
 /**
  * Return the list of Blocks of a given itemset
  * @param ItemSet $itemSet
  *
  * @return Block[]
  */
 public static function findAllByItemSet(ItemSet $itemSet)
 {
     $id = $itemSet->getId();
     $pdo = DatabaseManager::getConnection();
     $stmt = $pdo->prepare("SELECT * FROM block WHERE id_itemset = :id");
     $stmt->bindParam(':id', $id, \PDO::PARAM_INT);
     $stmt->execute();
     $array = $stmt->fetchAll();
     if ($array == false) {
         return [];
     }
     $blocks = [];
     foreach ($array as $data) {
         $block = new Block();
         $block->setId($data['id']);
         $block->setType($data['type']);
         $block->setRecMath(new \SplBool($data['recMath'] == 1 ? true : false));
         $block->setMinSummonerLevel(new \SplInt((int) $data['minSummonerLevel']));
         $block->setMaxSummonerLevel(new \SplInt((int) $data['maxSummonerLevel']));
         $api = ApiManager::getAPI();
         if ($data['showIfSummonerSpell'] != 0) {
             $block->setShowIfSummonerSpell($api->staticData()->getSummonerSpell($data['showIfSummonerSpell'], 'all'));
         }
         if ($data['hideIfSummonerSpell'] != 0) {
             $block->setHideIfSummonerSpell($api->staticData()->getSummonerSpell($data['hideIfSummonerSpell'], 'all'));
         }
         $block->setComment($data['comment']);
         $block->setItemSet($itemSet);
         $block->setItems(ItemBlock::findAllByBlock($block));
         $blocks[] = $block;
     }
     return $blocks;
 }