Пример #1
0
 /**
  * Attempt to extract the 'games' array, then pass control
  * back to {@link BBModel::import_values()}
  *
  * {@inheritdoc}
  */
 public function import_values($data)
 {
     //Found it!
     if (isset($data->games)) {
         //Now loop through each game as instantiate a new BBMatchGame for it
         $this->games = array();
         foreach ($data->games as &$game) {
             //Instantiate a new game, tell it to remember us, then store it in games[]
             $game = $this->bb->match_game($game);
             //If we have a tournament (we wouldn't if this was created directly from $bb), give each game a reference
             if (!is_null($this->tournament)) {
                 $game->init($this->tournament, $this);
             }
             $this->games[] = $game;
         }
     }
     //Let BBModal handle the rest, business as usual
     parent::import_values($data);
     //If not given a 'draw' value, initialize it as false
     if (!isset($this->data['draw'])) {
         $this->set_current_data('draw', false);
     }
 }
Пример #2
0
 /**
  * Overloads {@link BBModel::import_values} so we can handle 'hidden'
  *
  * {@inheritdoc}
  */
 public function import_values($data)
 {
     //Let BBModel handle default functionality
     parent::import_values($data);
     //json 'hidden' custom values
     if (array_key_exists('notes', $this->data)) {
         $notes = $this->data['notes'];
         if (is_string($notes)) {
             if (!is_null($notes = json_decode($notes))) {
                 $this->set_current_data('notes', $notes);
             }
         }
     }
 }