public function send(Request $request) { $functionUrl = $request->getBaseUrl() . '/' . $request->getFunction(); if (count($request->getUrlParams()) > 0) { $finalUrl = $functionUrl . '?' . http_build_query($request->getUrlParams()); } else { $finalUrl = $functionUrl; } $ch = curl_init($finalUrl); $headerArray = []; foreach ($request->getHeaders() as $key => $value) { $headerArray[] = ucfirst($key) . ': ' . $value; } curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $method = strtoupper($request->getMethod()); switch ($method) { case "GET": break; case "POST": curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getParams()); break; case "DELETE": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); break; case "PUT": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request->getParams())); break; } return json_decode(curl_exec($ch)); }
public function getResponse() { try { return new SuccesfullResponse($this->requestObject->getId(), $this->dispatchMethod($this->requestObject->getMethod(), $this->requestObject->getParams())); } catch (\Exception $e) { return new ErrorResponse($this->requestObject->getId(), array('message' => $e->getMessage(), 'code' => $e->getCode())); } }
public function sign(Request $request) { $currentHeaders = $request->getHeaders(); $signatureHeader = $this->getV1SignatureHeader($this->credentials->getPublicId(), base64_decode($this->credentials->getSecret())); $currentHeaders['x-signature'] = $signatureHeader; return new ApiRequest($request->getBaseUrl(), $request->getFunction(), $request->getUrlParams(), $request->getMethod(), $request->getParams(), $currentHeaders); }
/** * The constructor of Request * * @return void */ public function __construct() { self::$getParams = $_GET; self::$postParams = $_POST; self::$filesParams = $_FILES; self::$requestURL = $_SERVER["REQUEST_URI"]; self::$parameters = array(); }
public static function launch($strBoardName) { $strBoardFullPath = sprintf('%s\\board\\%s', Application::getInstance()->strApplicationClassesPrefix, $strBoardName); $objSpecifiedBoard = new $strBoardFullPath(); $objBoardMethod = new \ReflectionMethod($strBoardFullPath, 'index'); $arrRequestParams = Request::getParams(); $objResponse = $objBoardMethod->invokeArgs($objSpecifiedBoard, $arrRequestParams); return $objResponse; }
/** * Returns a View object. * * @route GET /?method=example.request * @route GET /example/request * * @param Request $request * @return View */ public function requestAction($request) { $view = new View(); $view->setLayout('main'); $view->method = $request->getMethod(); $view->controller = $request->getController(); $view->action = $request->getAction(); $view->baseUrl = $request->getBaseUrl(); $view->urlPath = $request->getUrlPath(); $view->params = $request->getParams(); return $view; }
static function init() { // recuperar la request echo $_SERVER['REQUEST_URI']; // extract all the components un URI Request::retrieve(); $controller = Request::getCont(); Coder::code($controller); $action = Request::getAct(); Coder::code($action); $params = Request::getParams(); Coder::codear($params); }
static function init() { //echo 'CORE arrenca app'; //recuperar la request //echo $_SERVER['REQUEST_URI']; Request::retrieve(); $controller = Request::getCont(); echo $controller . '</br>'; $action = Request::getAct(); echo $action . '</br>'; $params = Request::getParams(); //Printamos los parametros print_r($params); }
static function init() { // begining to extract // routing elements Request::retrieve(); $controller = Request::getCont(); self::$controller = $controller; $action = Request::getAct(); self::$action = $action; $params = Request::getParams(); // routing to the correspondig // controller self::router(); }
static function init() { //echo 'Core arrenca app'; //recuperar el request //echo $_SERVER['REQUEST_URI']; Request::retrieve(); $controller = Request::getCont(); self::$controller = $controller; //Coder::code($controller); $action = Request::getAct(); self::$action = $action; //Coder::code($action); $params = Request::getParams(); //Coder::codear($params); self::router(); }
/** * Overriding parent * * @param string $name * @return mixed */ public function __get($name) { if ($name == 'session') { if ($this->_session === null) { $req = $this->request; Loader::load('Session', 'core'); $ns = $req->getController(); $subdir = str_replace('/', '_', $req->getControllerSubDirectory()); if ($subdir != '') { $ns = $subdir . '_' . $ns; } $this->_session = new Session($ns); } return $this->_session; } if ($name == 'post') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getPost(); } return $this->_caches[$name]; } if ($name == 'query') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getQuery(); } return $this->_caches[$name]; } if ($name == 'params') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getParams(); } return $this->_caches[$name]; } if ($name == 'controller') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getController(); } return $this->_caches[$name]; } if ($name == 'action') { if (!array_key_exists($name, $this->_caches)) { $this->_caches[$name] = $this->request->getAction(); } return $this->_caches[$name]; } return parent::__get($name); }
static function init() { //echo 'CORE arrenca app' //recuperar to request //echo $_SERVER['REQUEST_URI']; Request::retrieve(); $controller = Request::getCont(); $action = Request::getAct(); $params = Request::getParams(); //mostramos los datos /*coder::code($controller); coder::code($action); coder::codear($params);*/ //router self::$controller = $controller; self::$action = $action; self::$params = $params; self::router(); }
static function init() { //echo 'CORE arrenca app'; //recuperar la request //echo $_SERVER['REQUEST_URI']; Request::retrieve(); $controller = Request::getCont(); //ayuda en los errores self::$controller = $controller; //coder::code($controller); $action = Request::getAct(); //ayuda en los errores self::$action = $action; //coder::code($action); $params = Request::getParams(); //Printamos los parametros //print_r($params); //ayuda en los errores //coder::codear($params); self::router(); }
/** * Persists the entity data found in the request. * * @param Request $req The request instance * @param Response $res The response instance * * @return void * @see IndexServlet::indexAction() */ public function persistAction(Request $req, Response $res) { // load the params with the entity data $parameterMap = $req->getParams(); // check if the necessary params has been specified and are valid if (!array_key_exists('sampleId', $parameterMap)) { throw new \Exception(); } else { $sampleId = filter_var($parameterMap['sampleId'], FILTER_VALIDATE_INT); } if (!array_key_exists('name', $parameterMap)) { throw new \Exception(); } else { $name = filter_var($parameterMap['name'], FILTER_SANITIZE_STRING); } // create a new entity and persist it $entity = new Sample(); $entity->setSampleId((int) $sampleId); $entity->setName($name); $this->getProxy(self::PROXY_CLASS)->persist($entity); // reload all entities and render the dialog $this->indexAction($req, $res); }
<?php mb_internal_encoding('UTF-8'); error_reporting(E_ALL); ini_set('display_errors', 1); include_once 'include.php'; $session = Session::getInstace(); $request = new Request(); $params = $request->getParams(); //Route::start(); $action = isset($params['action']) ? $params['action'] : 'index'; switch ($action) { //START POSTS//////////////////////////////////////////////////////////////////////////////////////////////// case 'index': $controller = new Controller_Post($params); $controller->actionIndex(); break; case 'view-post': $controller = new Controller_Post($params); $controller->actionViewPost(); break; case 'add-post': $controller = new Controller_Post($params); $controller->actionAddPost(); break; case 'do-new-post': $controller = new Controller_Post($params); $controller->actionDoNewPost(); break; case 'dell-post': $controller = new Controller_Post($params);
public function __construct(Application $app, Request $request) { $this->app = $app; $this->request = $request; $this->params = $request->getParams(); }
/** * Return all parameters in the {@link $_request Request object} * as an associative array. * * @return array */ protected function _getAllParams() { return $this->_request->getParams(); }
public function headAction() { return array("head" => Request::getParams()); }
/** * 获取并分析$_GET或$_POST全局超级变量数组某参数的值 * * 获取并分析$_POST['参数']的值 ,当$_POST['参数']不存在或为空时,再获取$_GET['参数']的值 * * @access public * * @param string $key 所要获取的参数名称 * @param mixed $default 默认参数, 注:只有$string不为数组时有效 * @param boolean $isEncode 是否对符串进行htmlspecialchars()转码(true:是/ false:否) * * @return mixed */ public static function getParams($key = null, $default = null, $isEncode = true) { return Request::getParams($key, $default, $isEncode); }