当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getMethod方法代码示例

本文整理汇总了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;
 }
开发者ID:tripomatic,项目名称:nette-api,代码行数:17,代码来源:Presenter.php

示例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;
 }
开发者ID:dzibma,项目名称:rest-api,代码行数:11,代码来源:Presenter.php

示例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
 }
开发者ID:tomasstrejcek,项目名称:Translation,代码行数:18,代码来源:LocaleParamResolver.php

示例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');
 }
开发者ID:Arachne,项目名称:Forms,代码行数:42,代码来源:ApplicationRequestHandler.php

示例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());
 }
开发者ID:vbuilder,项目名称:framework,代码行数:15,代码来源:Presenter.php


注:本文中的Nette\Application\Request::getMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。