本文整理汇总了PHP中Nette\Http\IRequest::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP IRequest::getMethod方法的具体用法?PHP IRequest::getMethod怎么用?PHP IRequest::getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\IRequest
的用法示例。
在下文中一共展示了IRequest::getMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCode
/**
* Get default status code
* @param int|null $code
* @return null
*/
protected function getCode($code = NULL)
{
if ($code === NULL) {
$code = $code = isset($this->defaultCodes[$this->request->getMethod()]) ? $this->defaultCodes[$this->request->getMethod()] : 200;
}
return (int) $code;
}
示例2: getPreferredMethod
/**
* Get prederred method
* @param IRequest $request
* @return string
*/
protected function getPreferredMethod(IRequest $request)
{
$method = $request->getMethod();
$isPost = $method === IRequest::POST;
$header = $request->getHeader(self::OVERRIDE_HEADER);
$param = $request->getQuery(self::OVERRIDE_PARAM);
if ($header && $isPost) {
return $header;
}
if ($param && $isPost) {
return $param;
}
return $request->getMethod();
}
示例3: getPanel
/**
* Renders panel.
* @return string
*/
public function getPanel()
{
ob_start();
$request = $this->request;
$routers = $this->routers;
$source = $this->source;
$hasModule = (bool) array_filter($routers, function ($rq) {
return $rq['module'];
});
$url = $this->httpRequest->getUrl();
$method = $this->httpRequest->getMethod();
require __DIR__ . '/templates/RoutingPanel.panel.phtml';
return ob_get_clean();
}
示例4: match
/**
* Maps HTTP request to a Request object.
* @return Nette\Application\Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
if ($httpRequest->getUrl()->getPathInfo() !== '') {
return NULL;
}
// combine with precedence: get, (post,) defaults
$params = $httpRequest->getQuery();
$params += $this->defaults;
if (!isset($params[self::PRESENTER_KEY]) || !is_string($params[self::PRESENTER_KEY])) {
return NULL;
}
$presenter = $this->module . $params[self::PRESENTER_KEY];
unset($params[self::PRESENTER_KEY]);
return new Application\Request(
$presenter,
$httpRequest->getMethod(),
$params,
$httpRequest->getPost(),
$httpRequest->getFiles(),
array(Application\Request::SECURED => $httpRequest->isSecured())
);
}
示例5: match
/**
* Maps HTTP request to a Request object.
*
* @param Nette\Http\IRequest $httpRequest
* @return Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
$relativeUrl = trim($httpRequest->getUrl()->relativeUrl, "/");
$path = trim($httpRequest->getUrl()->path, "/");
if ($relativeUrl == "") {
$target = $this->defaultRoute;
$this->currentTarget->setCurrentTarget($this->targetDao->findTarget($target->presenter, $target->action, $target->id));
} elseif ($relativeUrl == "sitemap.xml") {
$target = new Target("Seo:Meta", "sitemap");
} elseif ($relativeUrl == "robots.txt") {
$target = new Target("Seo:Meta", "robots");
} elseif (substr($relativeUrl, 0, 6) == "google" && $this->settingsDao->getWebmasterToolsName() == $relativeUrl) {
$target = new Target("Seo:Meta", "googleWebmasterTools");
} else {
$route = $this->routeDao->findRouteBySlug($relativeUrl, TRUE);
if (!$route) {
$route = $this->routeDao->findRouteBySlug($path, TRUE);
if (!$route) {
return NULL;
}
}
$this->currentTarget->setCurrentTarget($route->getTarget());
$target = new Target($route->target->targetPresenter, $route->target->targetAction, $route->target->targetId);
}
$params = array();
$params["action"] = $target->action;
if ($target->id) {
$params["id"] = $target->id;
}
$params += $httpRequest->getQuery();
return new Request($target->presenter, $httpRequest->getMethod(), $params, $httpRequest->getPost(), $httpRequest->getFiles(), array(Request::SECURED => $httpRequest->isSecured()));
}
示例6: match
/**
* CLI commands run from app/console.php
*
* Maps HTTP request to a Request object.
* @return Nette\Application\Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
$this->loadLocales();
$urlPath = new Services\UrlPath($httpRequest);
$urlPath->setPredefinedLocales($this->locales);
/** @var Url $urlEntity */
$urlEntity = $this->loadUrlEntity($urlPath->getPath(true));
if ($urlEntity === null) {
// no route found
$this->onUrlNotFound($urlPath);
return null;
}
if ($urlEntity->getActualUrlToRedirect() === null) {
$presenter = $urlEntity->getPresenter();
$internal_id = $urlEntity->getInternalId();
$action = $urlEntity->getAction();
} else {
$presenter = $urlEntity->getActualUrlToRedirect()->getPresenter();
$internal_id = $urlEntity->getActualUrlToRedirect()->getInternalId();
$action = $urlEntity->getActualUrlToRedirect()->getAction();
}
$params = $httpRequest->getQuery();
$params['action'] = $action;
$params['locale'] = $urlPath->getLocale();
$this->urlParametersConverter->in($urlEntity, $params);
// todo
if ($internal_id !== null) {
$params['internal_id'] = $internal_id;
}
return new Nette\Application\Request($presenter, $httpRequest->getMethod(), $params, $httpRequest->getPost(), $httpRequest->getFiles());
}
示例7: getMethod
/**
* Get request method flag
* @param Http\IRequest $httpRequest
* @return string|null
*/
public function getMethod(Http\IRequest $httpRequest)
{
$method = $httpRequest->getMethod();
if (!isset($this->methodDictionary[$method])) {
return NULL;
}
return $this->methodDictionary[$method];
}
示例8: match
/**
* Match request
* @param IRequest $request
* @return Request
*/
public function match(Http\IRequest $request)
{
$path = $request->url->getPathInfo();
if (!Strings::contains($path, $this->prefix)) {
return NULL;
}
$path = Strings::substring($path, strlen($this->prefix) + 1);
$pathParts = explode('/', $path);
$pathArguments = array_slice($pathParts, 1);
$action = $this->getActionName($request->getMethod(), $pathArguments);
$params = $this->getPathParameters($pathArguments);
$params[Route::MODULE_KEY] = $this->module;
$params[Route::PRESENTER_KEY] = $pathParts[0];
$params['action'] = $action;
$presenter = ($this->module ? $this->module . ':' : '') . $params[Route::PRESENTER_KEY];
$appRequest = new Application\Request($presenter, $request->getMethod(), $params, $request->getPost(), $request->getFiles());
return $appRequest;
}
示例9: detectHttpMethod
/**
* @param Http\IRequest $httpRequest
* @return string
*/
private function detectHttpMethod(Http\IRequest $httpRequest)
{
$method = $httpRequest->getMethod();
if ($this->headerOverride && $method === Http\IRequest::POST) {
$overriden = $httpRequest->getHeader($this->headerOverride);
$method = $overriden ? strtoupper($overriden) : $method;
}
return $method;
}
示例10: match
public function match(\Nette\Http\IRequest $httpRequest)
{
$httpMethod = $httpRequest->getMethod();
$flags = $this->getFlags();
if (($flags & self::RESTFUL) == self::RESTFUL) {
$presenterRequest = parent::match($httpRequest);
if ($presenterRequest != NULL) {
switch ($httpMethod) {
case 'GET':
$action = 'default';
break;
case 'POST':
$action = 'create';
break;
case 'PUT':
$action = 'update';
break;
case 'PATCH':
$action = 'update';
break;
case 'DELETE':
$action = 'delete';
break;
default:
$action = 'default';
}
$params = $presenterRequest->getParameters();
$params['action'] = $action;
$presenterRequest->setParameters($params);
return $presenterRequest;
} else {
return NULL;
}
}
if (($flags & self::METHOD_POST) == self::METHOD_POST && $httpMethod != 'POST') {
return NULL;
}
if (($flags & self::METHOD_GET) == self::METHOD_GET && $httpMethod != 'GET') {
return NULL;
}
if (($flags & self::METHOD_PUT) == self::METHOD_PUT && $httpMethod != 'PUT') {
return NULL;
}
if (($flags & self::METHOD_PATCH) == self::METHOD_PATCH && $httpMethod != 'PATCH') {
return NULL;
}
if (($flags & self::METHOD_DELETE) == self::METHOD_DELETE && $httpMethod != 'DELETE') {
return NULL;
}
return parent::match($httpRequest);
}
示例11: match
public function match(\Nette\Http\IRequest $httpRequest)
{
$httpMethod = $httpRequest->getMethod();
if (($this->flags & self::RESTFUL) == self::RESTFUL) {
$presenterRequest = parent::match($httpRequest);
if ($presenterRequest != NULL) {
$payload = null;
$payloadParameters = array();
switch ($httpMethod) {
case 'GET':
$action = 'default';
break;
case 'POST':
$action = 'create';
break;
case 'PUT':
$action = 'update';
$payload = file_get_contents("php://input");
parse_str($payload, $payloadParameters);
break;
case 'DELETE':
$action = 'delete';
break;
default:
$action = 'default';
}
$parameters = $presenterRequest->getParameters();
$parameters['action'] = $action;
$parameters['payload'] = $payload;
$parameters = array_merge($parameters, $payloadParameters);
$presenterRequest->setParameters($parameters);
return $presenterRequest;
} else {
return NULL;
}
}
if (($this->flags & self::METHOD_POST) == self::METHOD_POST && $httpMethod != 'POST') {
return NULL;
}
if (($this->flags & self::METHOD_GET) == self::METHOD_GET && $httpMethod != 'GET') {
return NULL;
}
if (($this->flags & self::METHOD_PUT) == self::METHOD_PUT && $httpMethod != 'PUT') {
return NULL;
}
if (($this->flags & self::METHOD_DELETE) == self::METHOD_DELETE && $httpMethod != 'DELETE') {
return NULL;
}
return parent::match($httpRequest);
}
示例12: match
public function match(IRequest $httpRequest)
{
$httpMethod = $httpRequest->getMethod();
if (($this->flags & self::RESTFUL) == self::RESTFUL) {
$presenterRequest = parent::match($httpRequest);
if ($presenterRequest != NULL) {
switch ($httpMethod) {
//see: http://en.wikipedia.org/wiki/Representational_state_transfer#RESTful_web_APIs
case 'GET':
$action = 'get';
break;
case 'POST':
$action = 'post';
break;
//CREATE
//CREATE
case 'PUT':
$action = 'put';
break;
//UPDATE
//UPDATE
case 'DELETE':
$action = 'delete';
break;
default:
$action = 'get';
}
$params = $presenterRequest->getParameters();
$params['action'] = $action;
$presenterRequest->setParameters($params);
return $presenterRequest;
} else {
return NULL;
}
}
if (($this->flags & self::METHOD_POST) == self::METHOD_POST && $httpMethod != 'POST') {
return NULL;
}
if (($this->flags & self::METHOD_GET) == self::METHOD_GET && $httpMethod != 'GET') {
return NULL;
}
if (($this->flags & self::METHOD_PUT) == self::METHOD_PUT && $httpMethod != 'PUT') {
return NULL;
}
if (($this->flags & self::METHOD_DELETE) == self::METHOD_DELETE && $httpMethod != 'DELETE') {
return NULL;
}
return parent::match($httpRequest);
}
示例13: match
/**
* Maps HTTP request to a Request object.
*
* @param Nette\Http\IRequest $httpRequest
* @return NULL|Request
*/
public function match(Nette\Http\IRequest $httpRequest)
{
$slug = ltrim($httpRequest->getUrl()->getPath(), '/');
$id = $this->dibi->query('
SELECT [c.id]
FROM [old_links] [l]
INNER JOIN [contents] [c] ON [c.youtube_id] = [l.target]
WHERE [mask] = %s', $slug, '
')->fetchSingle();
if (!$id) {
return NULL;
}
return new Request('Video', $httpRequest->getMethod(), ['action' => 'default', 'videoId' => $id]);
}
示例14: match
/**
* Maps HTTP request to a Request object.
*
* @return AppRequest|NULL
*/
public function match(HttpRequest $httpRequest)
{
$url = $httpRequest->getUrl();
$slug = rtrim(substr($url->getPath(), strrpos($url->getScriptPath(), '/') + 1), '/');
foreach ($this->tableOut as $destination2 => $slug2) {
if ($slug === rtrim($slug2, '/')) {
$destination = $destination2;
break;
}
}
if (!isset($destination)) {
return NULL;
}
$params = $httpRequest->getQuery();
$pos = strrpos($destination, ':');
$presenter = substr($destination, 0, $pos);
$params['action'] = substr($destination, $pos + 1);
return new AppRequest($presenter, $httpRequest->getMethod(), $params, $httpRequest->getPost(), $httpRequest->getFiles(), array(AppRequest::SECURED => $httpRequest->isSecured()));
}
示例15: match
/**
* Maps HTTP request to a Request object.
*
* @param Http\IRequest $httpRequest
* @return NULL|Request
*/
public function match(Http\IRequest $httpRequest)
{
$path = ltrim($httpRequest->getUrl()->getPath(), '/');
$match = Strings::match($path, '~^([^/]+)/(?P<slug>[^/]+)/lekce~');
if (!$match) {
return NULL;
}
$id = $this->dibi->query('
SELECT [c.id]
FROM [old_links] [l]
INNER JOIN [contents] [c] ON [c.youtube_id] = [l.target]
WHERE [mask] = %s', $match['slug'], '
')->fetchSingle();
if (!$id) {
return NULL;
}
return new Request('Video', $httpRequest->getMethod(), ['action' => 'default', 'videoId' => $id]);
}