public function handle($data) { $method = $data['method']; $restData = Json::decode($data['rest_data']); $class = '\\Tests\\MockSugarServer\\Action\\' . Strings::underscoreToCamelCase($method); $action = new $class($restData); return $action->process()->response(); }
public function index() { $field = $this->params['field']; $game = Game::currentGame(); $currentGameUser = $game->current_game_user; $leftShoots = $currentGameUser->getLeftShoots(); if ($leftShoots) { $hit = Hit::createFor($field, $currentGameUser); $params = Json::encode(['game' => $game->type, 'field' => $hit->field, 'multiplier' => $hit->multiplier, 'scored' => $hit->handleScore(), 'winner' => $currentGameUser->isWinner(), 'shots_left' => $leftShoots - 1, 'shitty_round' => $currentGameUser->isShittyRound()]); Event::create(['name' => 'hit', 'params' => $params]); } else { Event::create(['name' => 'next_player', 'params' => '']); } }
public function poll() { Stats::reset(); session_write_close(); $stop = Clock::now()->plusSeconds(self::TIMEOUT); while (true) { if (!$stop->isAfter(Clock::now()) || connection_aborted()) { $this->layout->renderAjax("[]"); return; } session_start(); $events = Event::loadNew(); session_write_close(); if ($events) { $this->layout->renderAjax(Json::encode(Arrays::map($events, function (Event $event) { return $event->toJsonArray(); }))); return; } Stats::reset(); usleep(100 * 1000); } }
public function getRestData() { $parameters = array("session" => Session::$sessionId, "i" => $this->documentId); return Json::encode($parameters); }
public function getRestData() { $parameters = array("session" => Session::$sessionId, "module_name" => $this->moduleName, "name_value_list" => $this->fields); return Json::encode($parameters); }
/** * @return array */ public function toJsonArray() { return ['name' => $this->name, 'params' => Json::decode($this->params)]; }
public function getRenderedJsonAsArray() { return Json::decode($this->getActualContent(), true); }
/** * @test * @dataProvider invalidJson * @param string $invalidJson */ public function shouldThrowOnInvalidJson($invalidJson) { // when try { Json::decode($invalidJson); $this->assertTrue(false); } catch (JsonDecodeException $e) { } }
public function getRestData() { $parameters = array('session' => Session::$sessionId, 'module_name' => $this->moduleName, 'fields' => $this->fields); return Json::encode($parameters); }
public function getRestData() { $parameters = array('session' => Session::$sessionId, 'module_name' => $this->moduleName, 'query' => $this->where, 'deleted' => 0); return Json::encode($parameters); }
private static function _jsonParameters($content) { if (Strings::equalsIgnoreCase(ContentType::value(), 'application/json')) { return Arrays::toArray(Json::decode($content, true)); } return false; }
public function getRestData() { $parameters = array('session' => Session::$sessionId, 'filter' => 'all'); return Json::encode($parameters); }
public function getRestData() { $parameters = array('session' => Session::$sessionId, 'module_name' => $this->moduleName, 'id' => $this->id, 'select_fields' => $this->fields, 'link_name_to_fields_array' => array(), 'track_view' => true); return Json::encode($parameters); }
public function getRestData() { $parameters = array("session" => Session::$sessionId, "note" => array('id' => $this->documentId, 'file' => base64_encode($this->content), 'filename' => $this->fileName, 'revision' => '1')); return Json::encode($parameters); }
public function getRestData() { $parameters = array('session' => Session::$sessionId, 'module_name' => $this->moduleName, 'module_id' => $this->moduleId, 'link_field_name' => $this->relationModuleDbName, 'related_module_query' => 0, 'related_fields' => $this->fields, 'related_module_link_name_to_fields_array' => array(), 'deleted' => 0); return Json::encode($parameters); }
public function getRestData() { $parameters = array('session' => Session::$sessionId, 'module_name' => $this->moduleName, 'query' => $this->where, 'order_by' => $this->orderBy, 'offset' => 0, 'select_fields' => $this->fields, 'link_name_to_fields_array' => '', 'max_result' => 100, 'deleted' => 0, 'favorites' => false); return Json::encode($parameters); }
public function getRestData() { $parameters = array('user_auth' => array('user_name' => $this->login, 'password' => $this->password, 'version' => 1), 'application_name' => 'RestTest', 'name_value_list' => array()); return Json::encode($parameters); }
public function getRestData() { $parameters = array('session' => Session::$sessionId, 'module_name' => $this->moduleName, 'module_id' => $this->moduleId, 'link_field_name' => $this->relationModuleDbName, 'related_ids' => array($this->relationModuleId), 'name_value_list' => array(), 'delete' => 0); return Json::encode($parameters); }