Esempio n. 1
0
 /**
  * Attempt to extract data sent from a BinaryBeast callback
  * 
  * <br />
  * This method will try to extract the data from $_POST and $_GET, and then
  * process the data further based on the event_id
  * 
  * <br /><br />
  * For example if a tourney_info array is provided, you'll get a full {@link BBTournament} instance
  * 
  * 
  * @return BBCallbackHandlerObject|boolean
  *	<b>FALSE</b> returned if unable to find any relevent data in $_POST and $_GET
  * 
  *	<br /><br />
  *	Refer to the properties documented in {@link BBCallbackObject} for values that you can expect
  * 
  *	<br /><br />
  *	In additon to the standard values in {@link BBCallbackObject}, each event may return data that this method will convert into <b>model objects</b><br/ >
  *	For example, if the callback sends a tourney_info array, you can expect <var>$tournament</var> to be a {@link BBTournament} model object
  * 
  *	<br /><br />
  *	Events that expect these values are documented in each event_id constant in this class
  */
 public function handle_callback()
 {
     //Prepare the object we'll be returning
     $data = new stdClass();
     //Figure out if we should use $_POST or $_GET, then save a refernece to $request
     $request = null;
     if (isset($_POST['callback_id'])) {
         $request =& $_POST;
     } else {
         if (isset($_GET['callback_id'])) {
             $request =& $_GET;
         } else {
             return $this->bb->set_error('Unable to locate a "callback_id" value in either $_POST or $_GET');
         }
     }
     //All standard callback values must be present
     $keys = array('callback_id', 'event_id', 'event_description', 'event_utc_date');
     foreach ($keys as $key) {
         if (!isset($request[$key])) {
             return $this->bb->set_error('Unable to locate a "' . $key . '" value, unable to process this as a valid callback', 'BBCallback');
         }
         $data->{$key} = $request[$key];
     }
     //Try to extract a tournament
     if (isset($request['tourney_info'])) {
         $data->tournament = $this->bb->tournament($request);
     } else {
         if (strpos($request['trigger_id'], 'x') === 0) {
             $data->tournament = $this->bb->tournament($request['trigger_id']);
         } else {
             if (isset($request['tourney_id'])) {
                 $data->tournament = $this->bb->tournament($request['tourney_id']);
             }
         }
     }
     //Try to extract a match
     if (isset($request['match_info'])) {
         if (isset($request['games'])) {
             $data->match = $this->bb->match($request);
         }
     } else {
         if (isset($request['tourney_match_id'])) {
             $data->match = $this->bb->match($request['tourney_match_id']);
         }
     }
     //Try to extract a team
     if (isset($request['team_info'])) {
         $data->team = $this->bb->team($request);
     } else {
         if (isset($request['tourney_team_id'])) {
             $data->team = $this->bb->team($request['tourney_team_id']);
         }
     }
     //Success!
     return $data;
 }
Esempio n. 2
0
 /**
  * Asserts the value of a team, but firsts loads the team externally
  *
  * This eliminates ANY chance of contaminated results, it loads a new
  * BBTeam directly from the API, and asserts the provided key=>value pair
  */
 public static function AssertTeamValueExternally($team, $key, $value)
 {
     if ($team instanceof BBTeam) {
         $team = $team->id;
     }
     self::assertInstanceOf('BBTeam', $team = self::$bb_static->team($team));
     //
     if (is_null($value)) {
         self::assertNull($team->{$key});
     } else {
         self::assertEquals($value, $team->{$key});
     }
 }
 /**
  * @covers BinaryBeast::team
  */
 public function test_team()
 {
     $this->assertInstanceOf('BBTeam', $this->object->team, '$this->object->team did not return a new BBTeam');
     $this->assertInstanceOf('BBTeam', $this->object->team(), '$this->object->team() did not return a new BBTeam');
 }