本文整理汇总了PHP中Zend\Http\PhpEnvironment\Request::isGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::isGet方法的具体用法?PHP Request::isGet怎么用?PHP Request::isGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\PhpEnvironment\Request
的用法示例。
在下文中一共展示了Request::isGet方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TreatRequest
public function TreatRequest()
{
$request = new Request();
if ($request->isGet()) {
$this->DoGet();
} else {
if ($request->isPost()) {
$this->DoPost();
} else {
return new \Exception();
}
}
}
示例2: TreatRequest
public function TreatRequest()
{
$req = new Request();
if ($req->isGet()) {
return $this->DoGet();
}
if ($req->isDelete() && $this->IsAuthorized()) {
return $this->DoDelete();
} else {
if ($req->isPost()) {
return $this->DoPost();
} else {
return new \Exception();
}
}
}
示例3: selectSite
/**
*
* {@inheritDoc}
*/
public function selectSite(Request $request, Response $response)
{
if (!$request->isGet()) {
return false;
}
$siteId = $request->getQuery('siteId', self::ENGLISH_SITE_ID);
$site = $this->siteService->find($siteId);
if (!$site) {
$siteId = self::ENGLISH_SITE_ID;
}
// Just in case
$this->siteId = $siteId;
$cookie = new SetCookie(self::SITE_ID_COOKIE, $siteId, time() + 30 * 24 * 60 * 60);
// now + 1 month
$response->getHeaders()->addHeader($cookie);
return true;
}
示例4: Edit
public function Edit()
{
if (CommonController::IsAuthentified()) {
$request = new Request();
if ($request->isGet()) {
$data = json_decode($this->GetCurrentCollection(), true);
if (!is_null($data)) {
CommonController::SetView("collection", "edit", array_merge($data, array('url' => array('edit' => CommonController::GetLink("Collection", "edit", $data['collection']['id'])))));
return;
}
} else {
if ($request->isPost()) {
$label = $request->getPost('label');
$description = $request->getPost('description');
$id = $request->getPost('id');
if (!is_null($label) && !is_null($description)) {
if (!is_null($id)) {
$WSCtrl = new WebServicesController();
$return = $WSCtrl->Call("Collection", "POST", array("id" => $id, "label" => $label, "description" => $description));
var_dump($return);
if ($return == "true") {
CommonController::Redirect("Collection", "Index", $id);
} else {
$data = json_decode($this->GetCurrentCollection(), true);
if (!is_null($data)) {
CommonController::SetView("collection", "index", array_merge($data, array('url' => array('edit' => CommonController::GetLink("Collection", "edit", $data['collection']['id']), 'delete' => CommonController::GetLink("Collection", "delete", $data['collection']['id'])), 'error' => 'Impossible de sauver la collection')));
return;
}
}
} else {
//Create
}
}
}
}
}
CommonController::Redirect("home");
}
示例5: TreatRequest
public function TreatRequest()
{
if ($this->IsAuthorized()) {
$request = new Request();
if ($request->isGet()) {
return $this->DoGet();
} else {
if ($request->isPost()) {
return $this->DoPost();
} else {
if ($request->isPut()) {
return $this->DoPut();
} else {
if ($request->isDelete()) {
return $this->DoDelete();
}
}
}
}
} else {
throw new \Exception();
}
}
示例6: Request
/**
* Validates a token.
*
* Automatically validates a token when a request has an header with authorization.
*
* @since 4.3.0
*
* @return int|false user-id when token is valid, false when it is invalid.
*/
function validate_token()
{
$request = new Request();
if ($request->isGet() || $request->isPost()) {
$authHeader = $request->getHeader('authorization');
if ($authHeader) {
list($jwt) = sscanf($authHeader->toString(), 'Authorization: Bearer %s');
if ($jwt) {
try {
$secretKey = base64_decode(get_option('jwt_secret'));
$token = JWT::decode($jwt, $secretKey, array('HS256'));
return $token->data->userId;
} catch (Exception $e) {
// FALSE if token is invalid
return false;
}
} else {
// FALSE if no token was passed
return false;
}
}
}
return false;
}
示例7: Request
<?php
chdir(dirname(__DIR__));
require_once 'vendor/autoload.php';
use Zend\Config\Config;
use Zend\Config\Factory;
use Zend\Http\PhpEnvironment\Request;
/*
* Get all headers from the HTTP request
*/
$request = new Request();
if ($request->isGet()) {
$authHeader = $request->getHeader('authorization');
/*
* Look for the 'authorization' header
*/
if ($authHeader) {
/*
* Extract the jwt from the Bearer
*/
list($jwt) = sscanf($authHeader->toString(), 'Authorization: Bearer %s');
if ($jwt) {
try {
$config = Factory::fromFile('config/config.php', true);
/*
* decode the jwt using the key from config
*/
$secretKey = base64_decode($config->get('jwt')->get('key'));
$token = JWT::decode($jwt, $secretKey, [$config->get('jwt')->get('algorithm')]);
$asset = base64_encode(file_get_contents('http://lorempixel.com/200/300/cats/'));
/*