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


PHP Request::isMethod方法代码示例

本文整理汇总了PHP中Nette\Application\Request::isMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::isMethod方法的具体用法?PHP Request::isMethod怎么用?PHP Request::isMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Application\Request的用法示例。


在下文中一共展示了Request::isMethod方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * @return Nette\Application\IResponse
  */
 public function run(Application\Request $request)
 {
     $this->request = $request;
     $httpRequest = $this->context->getByType('Nette\\Http\\IRequest');
     if (!$httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
         $refUrl = clone $httpRequest->getUrl();
         $url = $this->context->getService('router')->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
         if ($url !== NULL && !$httpRequest->getUrl()->isEqual($url)) {
             return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
         }
     }
     $params = $request->getParameters();
     if (!isset($params['callback'])) {
         throw new Application\BadRequestException("Parameter callback is missing.");
     }
     $params['presenter'] = $this;
     $callback = new Nette\Callback($params['callback']);
     $response = $callback->invokeArgs(Application\UI\PresenterComponentReflection::combineArgs($callback->toReflection(), $params));
     if (is_string($response)) {
         $response = array($response, array());
     }
     if (is_array($response)) {
         if ($response[0] instanceof \SplFileInfo) {
             $response = $this->createTemplate('Nette\\Templating\\FileTemplate')->setParameters($response[1])->setFile($response[0]);
         } else {
             $response = $this->createTemplate('Nette\\Templating\\Template')->setParameters($response[1])->setSource($response[0]);
         }
     }
     if ($response instanceof Nette\Templating\ITemplate) {
         return new Responses\TextResponse($response);
     } else {
         return $response;
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:37,代码来源:MicroPresenter.php

示例2: run

 /**
  * @param  Nette\Application\Request
  * @return Nette\Application\IResponse
  */
 public function run(Application\Request $request)
 {
     $this->request = $request;
     $httpRequest = $this->context->httpRequest;
     if (!$httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
         $refUrl = clone $httpRequest->getUrl();
         $url = $this->context->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
         if ($url !== NULL && !$httpRequest->getUrl()->isEqual($url)) {
             return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
         }
     }
     $params = $request->getParams();
     if (!isset($params['callback'])) {
         return;
     }
     $params['presenter'] = $this;
     $response = callback($params['callback'])->invokeNamedArgs($params);
     if (is_string($response)) {
         $response = array($response, array());
     }
     if (is_array($response)) {
         if ($response instanceof \SplFileInfo) {
             $response = $this->createTemplate('Nette\\Templating\\FileTemplate')->setParams($response[1])->setFile($response[0]);
         } else {
             $response = $this->createTemplate('Nette\\Templating\\Template')->setParams($response[1])->setSource($response[0]);
         }
     }
     if ($response instanceof Nette\Templating\ITemplate) {
         return new Responses\TextResponse($response);
     } else {
         return $response;
     }
 }
开发者ID:kovkus,项目名称:r-cms,代码行数:37,代码来源:MicroPresenter.php

示例3: run

	/**
	 * @return Nette\Application\IResponse
	 */
	public function run(Application\Request $request)
	{
		$this->request = $request;

		if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
			$refUrl = clone $this->httpRequest->getUrl();
			$url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
			if ($url !== NULL && !$this->httpRequest->getUrl()->isEqual($url)) {
				return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
			}
		}

		$params = $request->getParameters();
		if (!isset($params['callback'])) {
			throw new Application\BadRequestException('Parameter callback is missing.');
		}
		$params['presenter'] = $this;
		$callback = $params['callback'];
		$reflection = Nette\Utils\Callback::toReflection(Nette\Utils\Callback::check($callback));
		$params = Application\UI\PresenterComponentReflection::combineArgs($reflection, $params);

		if ($this->context) {
			foreach ($reflection->getParameters() as $param) {
				if ($param->getClassName()) {
					unset($params[$param->getPosition()]);
				}
			}

			$params = Nette\DI\Helpers::autowireArguments($reflection, $params, $this->context);
			$params['presenter'] = $this;
		}

		$response = call_user_func_array($callback, $params);

		if (is_string($response)) {
			$response = array($response, array());
		}
		if (is_array($response)) {
			list($templateSource, $templateParams) = $response;
			$response = $this->createTemplate()->setParameters($templateParams);
			if (!$templateSource instanceof \SplFileInfo) {
				$response->getLatte()->setLoader(new Latte\Loaders\StringLoader);
			}
			$response->setFile($templateSource);
		}
		if ($response instanceof Application\UI\ITemplate) {
			return new Responses\TextResponse($response);
		} else {
			return $response;
		}
	}
开发者ID:nakoukal,项目名称:fakturace,代码行数:54,代码来源:MicroPresenter.php

示例4: canonicalize

 /**
  * Conditional redirect to canonicalized URI.
  * @return void
  * @throws Nette\Application\AbortException
  */
 public function canonicalize()
 {
     if (!$this->isAjax() && ($this->request->isMethod('get') || $this->request->isMethod('head'))) {
         $url = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->params, 'redirectX');
         if ($url !== NULL && !$this->getHttpRequest()->getUrl()->isEqual($url)) {
             $this->sendResponse(new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY));
         }
     }
 }
开发者ID:JakubKohout,项目名称:nette,代码行数:14,代码来源:Presenter.php

示例5: run

 /**
  * @param \Nette\Application\Request $request
  * @return \Nette\Application\IResponse
  * @throws \Nette\Application\BadRequestException
  */
 public function run(Application\Request $request)
 {
     $this->request = $request;
     if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
         $refUrl = clone $this->httpRequest->getUrl();
         $url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
         if ($url !== NULL && !$this->httpRequest->getUrl()->isEqual($url)) {
             return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
         }
     }
     $params = $request->getParameters();
     if (!isset($params['id'])) {
         throw new Application\BadRequestException('Parameter id is missing.');
     }
     if (NULL === ($item = $this->context->getService('webloader.cache')->getItem(\Nette\Utils\Strings::webalize($params['id'])))) {
         return new Responses\TextResponse('');
     }
     return new \Lohini\WebLoader\WebLoaderResponse($item[WebLoader::CONTENT], $item[WebLoader::CONTENT_TYPE], $item[WebLoader::ETAG]);
 }
开发者ID:lohini,项目名称:webloader,代码行数:24,代码来源:WebLoaderPresenter.php

示例6: canonicalize

 /**
  * Conditional redirect to canonicalized URI.
  * @return void
  * @throws Nette\Application\AbortException
  */
 public function canonicalize()
 {
     if (!$this->isAjax() && ($this->request->isMethod('get') || $this->request->isMethod('head'))) {
         try {
             $url = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->getParameters(), 'redirectX');
         } catch (InvalidLinkException $e) {
         }
         if (isset($url) && !$this->httpRequest->getUrl()->isEqual($url)) {
             $this->sendResponse(new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY));
         }
     }
 }
开发者ID:pdostal,项目名称:nette-blog,代码行数:17,代码来源:Presenter.php

示例7: run

 /**
  * @param Application\Request $request
  *
  * @return Application\IResponse
  *
  * @throws Application\BadRequestException
  */
 public function run(Application\Request $request)
 {
     $this->request = $request;
     if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
         $refUrl = clone $this->httpRequest->getUrl();
         $url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
         if ($url !== NULL && !$this->httpRequest->getUrl()->isEqual($url)) {
             return new Application\Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
         }
     }
     $params = $request->getParameters();
     if (!isset($params['action'])) {
         throw new Application\BadRequestException('Parameter action is missing.');
     }
     if (!isset($params['id'])) {
         throw new Application\BadRequestException('Parameter id is missing.');
     }
     // calls $this->action<Action>()
     if (!($response = $this->tryCall(Application\UI\Presenter::formatActionMethod(Utils\Strings::capitalize($params['action'])), $params))) {
         throw new Application\BadRequestException('Action not callable.');
     }
     return $response;
 }
开发者ID:ales-zrak,项目名称:assets-loader,代码行数:30,代码来源:Presenter.php

示例8: run

 public function run(Request $request)
 {
     $this->request = $request;
     try {
         $this->startup();
         $this->response = NULL;
         if ($this->checkSsl) {
             $this->checkSsl();
         }
         $this->checkApiVersion();
         $name = $this->request->presenterName;
         $action = isset($this->request->parameters['action']) ? $this->request->parameters['action'] : 'default';
         // kontrola dat
         if ($request->isMethod('post') || $request->isMethod('put') || $request->isMethod('patch')) {
             $this->getRawPostData();
             $this->prepareData($name, $action);
         }
         // kontrola přístupu
         if ($this->checkAccess) {
             $this->checkAccess($action);
         }
         $this->despatch($request, $action);
         if (!$this->response) {
             $this->response = new ApiResponse($this->payload, ApiResponse::S200_OK);
         }
     } catch (Nette\Application\AbortException $e) {
         // pass
     } catch (\Exception $e) {
         Nette\Diagnostics\Debugger::log($e);
         $this->response = NULL;
     }
     if (!$this->response) {
         $this->response = new ApiResponse(array(), ApiResponse::S500_INTERNAL_SERVER_ERROR);
     }
     if (isset($this->logger)) {
         $this->logRequest($request);
     }
     return $this->response;
 }
开发者ID:gorocacher,项目名称:RestApiBase,代码行数:39,代码来源:ApiPresenter.php

示例9: run

 /**
  * @param Request $request
  */
 public function run(Request $request)
 {
     if ($request->isMethod('get') && isset($request->getParameters()[RequestStorage::REQUEST_KEY])) {
         $stored = $this->requestStorage->loadRequest($request->getParameters()[RequestStorage::REQUEST_KEY]);
         /** @var Request $stored */
         if ($stored && $stored->getPresenterName() === $request->getPresenterName()) {
             $stored->setFlag(Request::RESTORED, true);
             $parameters = $stored->getParameters();
             if (isset($request->getParameters()[Presenter::FLASH_KEY])) {
                 $parameters[Presenter::FLASH_KEY] = $request->getParameters()[Presenter::FLASH_KEY];
             } else {
                 unset($parameters[Presenter::FLASH_KEY]);
             }
             $stored->setParameters($parameters);
             $request = $stored;
         }
     }
     return parent::run($request);
 }
开发者ID:enumag,项目名称:application,代码行数:22,代码来源:RequestStoragePresenterTrait.php


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