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


PHP IRequest::getMethod方法代码示例

本文整理汇总了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;
 }
开发者ID:lucien144,项目名称:Restful,代码行数:12,代码来源:ResponseFactory.php

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

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

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

示例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()));
 }
开发者ID:brabijan,项目名称:nette-seo-components,代码行数:38,代码来源:DbRouter.php

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

示例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];
 }
开发者ID:drahak,项目名称:restful,代码行数:13,代码来源:ResourceRoute.php

示例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;
 }
开发者ID:marten-cz,项目名称:Restful,代码行数:23,代码来源:StrictRoute.php

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

示例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);
 }
开发者ID:dansilovsky,项目名称:calendar,代码行数:51,代码来源:RestRoute.php

示例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);
 }
开发者ID:bazo,项目名称:translation-ui,代码行数:50,代码来源:RestRoute.php

示例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);
 }
开发者ID:krausv,项目名称:www.zeminem.cz,代码行数:49,代码来源:RestRouter.php

示例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]);
    }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:22,代码来源:OldCategory.php

示例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()));
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:24,代码来源:StaticRouter.php

示例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]);
    }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:26,代码来源:OldVideo.php


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