本文整理汇总了PHP中Nette\Application\Request::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getMethod方法的具体用法?PHP Request::getMethod怎么用?PHP Request::getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\Request
的用法示例。
在下文中一共展示了Request::getMethod方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @param Request $request
* @return IResponse
* @throws BadRequestException
*/
public function run(Request $request)
{
$method = strtolower($request->getMethod());
if (!method_exists($this, $method)) {
throw new BadRequestException("Method '{$request->getMethod()}' not supported.");
}
$response = $this->{$method}($request);
if (!$response instanceof IResponse) {
throw new InvalidStateException("Presenter '{$request->getPresenterName()}' did not return any response for method '{$request->getMethod()}'.");
}
return $response;
}
示例2: getAction
/**
* @return string
*/
public function getAction($fullyQualified = false)
{
if ($this->action === null) {
$method = $this->request->getMethod();
$this->action = isset(self::$actionMap[$method]) ? self::$actionMap[$method] : strtolower($method);
}
return $fullyQualified ? "{$this->request->getPresenterName()}:{$this->action}" : $this->action;
}
示例3: onRequest
/**
* @param Application $sender
* @param Request $request
*/
public function onRequest(Application $sender, Request $request)
{
$params = $request->getParameters();
if ($request->getMethod() === Request::FORWARD && empty($params['locale'])) {
return;
}
$this->request = $request;
if (!$this->translator) {
return;
}
$this->translator->setLocale(NULL);
$this->translator->getLocale();
// invoke resolver
}
示例4: handleRequest
/**
* @param FormInterface $form
* @param Request $request
*/
public function handleRequest(FormInterface $form, $request = null)
{
if (!$request instanceof Request) {
throw new UnexpectedTypeException($request, 'Nette\\Application\\Request');
}
$name = $form->getName();
if ($name === '') {
throw new InvalidArgumentException('Forms are not allowed to have an emtpy string as name.');
}
$method = $form->getConfig()->getMethod();
if ($method !== $request->getMethod()) {
return;
}
if ($method === 'GET') {
$get = $request->getParameters();
// Don't submit GET requests if the form's name does not exist in the request.
if (!isset($get[$name])) {
return;
}
$data = $get[$name];
} else {
$post = $request->getPost();
$files = $request->getFiles();
$default = $form->getConfig()->getCompound() ? [] : null;
$postData = isset($post[$name]) ? $post[$name] : $default;
$filesData = isset($files[$name]) ? $files[$name] : $default;
if (is_array($postData) && is_array($filesData)) {
$data = array_replace_recursive($postData, $filesData);
} else {
$data = $postData ?: $filesData;
}
// Don't submit the form if it is not present in the request.
if (!$data) {
return;
}
}
$form->submit($data, $method !== 'PATCH');
}
示例5: link
/**
* Returns absolute URL for given resource path
*
* @internal
*
* @param string resource path
* @param array of parameters
*
* @return string absolute url
*/
public function link($path = NULL, array $parameters = array())
{
$r = new Nette\Application\Request($this->appRequest->getPresenterName(), $this->appRequest->getMethod(), array_merge(array('action' => 'default', self::PARAM_KEY_PATH => ltrim($path, '/')), $parameters));
return $this->application->getRouter()->constructUrl($r, $this->httpRequest->getUrl());
}