/**
  * Convert the POST variable
  */
 public function parse()
 {
     //Title
     if (isset($_POST['title'])) {
         $this->itemSet->setTitle($_POST['title']);
     } else {
         $this->itemSet->setTitle("Item Set");
     }
     //Type
     if (isset($_POST['champion'])) {
         $champion = $this->champions->getChampion($_POST['champion']);
         if ($champion != null) {
             $this->itemSet->setChampion($champion);
         }
     }
     //Type
     if (isset($_POST['type'])) {
         $this->itemSet->setType(ItemSetType::getItemSetType($_POST['type']));
     }
     //Map
     if (isset($_POST['map'])) {
         $this->itemSet->setMap(Map::getMap($_POST['map']));
     }
     //Mode
     if (isset($_POST['mode'])) {
         $this->itemSet->setMode(Mode::getMode($_POST['mode']));
     }
     //Priority
     if (isset($_POST['priority'])) {
         $this->itemSet->setPriority(new \SplBool($_POST['priority'] == true));
     }
     //Sort Rank
     if (isset($_POST['sortrank'])) {
         $this->itemSet->setSortrank(new \SplInt(@(int) $_POST['sortrank']));
     }
     //Comments
     if (isset($_POST['comment'])) {
         $this->itemSet->setComment($_POST['comment']);
     }
     if (isset($_POST['blocks'])) {
         ksort($_POST['blocks']);
         foreach ($_POST['blocks'] as $block) {
             $b = $this->parseBlock($block);
             if ($b != null) {
                 $this->itemSet->addBlock($b);
             }
         }
     }
 }
 /**
  * @param array $json Convert the given php array from json to the internal item set
  */
 public function parse(array $json)
 {
     //Title
     if (isset($json['title'])) {
         $this->itemSet->setTitle(new \SplString($json['title']));
     } else {
         $this->itemSet->setTitle(new \SplString("Item Set"));
     }
     //Type
     if (isset($json['type'])) {
         $this->itemSet->setType(ItemSetType::getItemSetType($json['type']));
     }
     //Map
     if (isset($json['map'])) {
         $this->itemSet->setMap(Map::getMap($json['map']));
     }
     //Mode
     if (isset($json['mode'])) {
         $this->itemSet->setMode(Mode::getMode($json['mode']));
     }
     //Priority
     if (isset($json['priority'])) {
         $this->itemSet->setPriority(new \SplBool($json['priority'] == true));
     }
     //Sort Rank
     if (isset($json['sortrank'])) {
         $this->itemSet->setSortrank(new \SplInt(@(int) $json['sortrank']));
     }
     if (isset($json['blocks'])) {
         foreach ($json['blocks'] as $json_block) {
             $b = $this->parseBlock($json_block);
             if ($b !== null) {
                 $this->itemSet->addBlock($b);
             }
         }
     }
 }
Пример #3
0
 /**
  * Parse the array to add data to the current ItemSet
  * This is used to parse data from database
  * @param array $data
  */
 private function parseArray(array $data)
 {
     $this->setId($data['id']);
     $this->setTitle($data['title']);
     $this->setType(ItemSetType::getItemSetType($data['type']));
     $this->setMap(Map::getMap($data['map']));
     $this->setMode(Mode::getMode($data['mode']));
     $this->setPriority(new \SplBool($data['priority'] == 1 ? true : false));
     $this->setSortrank(new \SplInt((int) $data['sortrank']));
     $this->setComment($data['comment']);
     if ($data['champion'] != 0) {
         $this->setChampion(ApiManager::getAPI()->staticData()->getChampion($data['champion'], 'all'));
     }
     //No blocks as they are loading when needed
 }