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


PHP Http\IRequest类代码示例

本文整理汇总了PHP中Nette\Http\IRequest的典型用法代码示例。如果您正苦于以下问题:PHP IRequest类的具体用法?PHP IRequest怎么用?PHP IRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: 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

示例2: sendStorageFile

 /**
  * Sends chunked response to output.
  *
  * @param \MouseOver\Storage\IStorageFile $storageFile  Storage file
  * @param \Nette\Http\IRequest            $httpRequest  HTTP request
  * @param \Nette\Http\IResponse           $httpResponse HTTP response
  *
  * @return void
  */
 protected function sendStorageFile($storageFile, Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setHeader('Accept-Ranges', 'bytes');
     $reader = $storageFile->getReader();
     if (preg_match('#^bytes=(\\d*)-(\\d*)\\z#', $httpRequest->getHeader('Range'), $matches)) {
         list(, $start, $end) = $matches;
         if ($start === '') {
             $start = null;
         }
         if ($end === '') {
             $end = null;
         }
         try {
             $reader->setRange($start, $end);
         } catch (\InvalidArgumentException $invalidArgumentException) {
             $httpResponse->setCode(416);
             // requested range not satisfiable
             return;
         }
         $httpResponse->setCode(206);
         $httpResponse->setHeader('Content-Range', 'bytes ' . $reader->getRangeStart() . '-' . $reader->getRangeEnd() . '/' . $reader->getFileSize());
         $reader->setRange($start, $end);
         $httpResponse->setHeader('Content-Length', $reader->getLength());
     } else {
         $httpResponse->setHeader('Content-Range', 'bytes 0-' . ($reader->getFileSize() - 1) . '/' . $reader->getFileSize());
         $httpResponse->setHeader('Content-Length', $reader->getLength());
     }
     while ($reader->hasContent()) {
         echo $reader->read();
     }
 }
开发者ID:mouse-over,项目名称:storage,代码行数:40,代码来源:StorageFileResponse.php

示例3: match

 /**
  * Maps HTTP request to a Request object.
  * @return Nette\Application\Request|NULL
  */
 public function match(Nette\Http\IRequest $httpRequest)
 {
     // combine with precedence: mask (params in URL-path), fixity, query, (post,) defaults
     // 1) URL MASK
     $url = $httpRequest->getUrl();
     $re = $this->re;
     if ($this->type === self::HOST) {
         $path = '//' . $url->getHost() . $url->getPath();
         $host = array_reverse(explode('.', $url->getHost()));
         $re = strtr($re, array('/%basePath%/' => preg_quote($url->getBasePath(), '#'), '%tld%' => $host[0], '%domain%' => isset($host[1]) ? "{$host['1']}\\.{$host['0']}" : $host[0]));
     } elseif ($this->type === self::RELATIVE) {
         $basePath = $url->getBasePath();
         if (strncmp($url->getPath(), $basePath, strlen($basePath)) !== 0) {
             return NULL;
         }
         $path = (string) substr($url->getPath(), strlen($basePath));
     } else {
         $path = $url->getPath();
     }
     if ($path !== '') {
         $path = rtrim($path, '/') . '/';
     }
     if (!($matches = Strings::match($path, $re))) {
         // stop, not matched
         return NULL;
     }
     if (!$this->manager->isAMFRequest()) {
         return null;
     }
     return $this->manager->createApplicationRequest();
 }
开发者ID:goodshape,项目名称:nette-amf,代码行数:35,代码来源:Route.php

示例4: __construct

 /**
  * @param \DK\Translator\Loaders\Loader|string $pathOrLoader
  * @param \Nette\Http\IRequest $httpRequest
  */
 public function __construct($pathOrLoader, IRequest $httpRequest = null)
 {
     parent::__construct($pathOrLoader);
     if ($httpRequest !== null) {
         $this->debugMode = (bool) $httpRequest->getCookie(Panel::COOKIE_DEBUG_KEY);
     }
 }
开发者ID:carrooi,项目名称:nette-translator,代码行数:11,代码来源:Translator.php

示例5: isMobile

 /**
  * Detects mobile browser
  *
  * @author http://detectmobilebrowsers.com
  * @param IRequest $httpRequest
  * @return bool
  */
 public function isMobile(IRequest $httpRequest)
 {
     $useragent = $httpRequest->getHeader("user-agent");
     if (preg_match('/(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i', $useragent) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i', substr($useragent, 0, 4))) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:f3l1x,项目名称:nette-plugins,代码行数:15,代码来源:MobileRoute.php

示例6: 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

示例7: 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

示例8: match

 /**
  * Maps HTTP request to a Request object.
  *
  * @param Nette\Http\IRequest $httpRequest
  * @return NULL|Request
  */
 public function match(Nette\Http\IRequest $httpRequest)
 {
     $path = ltrim($httpRequest->getUrl()->getPath(), '/');
     if (Nette\Utils\Strings::match($path, '~^' . preg_quote($this->mask, '~') . '/*($|\\?)~')) {
         header("Location: {$this->target}", TRUE, 301);
         die;
     }
     return NULL;
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:15,代码来源:Redirect.php

示例9: parse

 /**
  * @param Http\Request $request
  * @return array
  */
 private function parse(Http\IRequest $request)
 {
     $params = array_merge($request->getPost(), $request->getQuery());
     if ($this->parser !== null) {
         $parsed = $this->parser->parse($request->getRawBody());
         $params = array_merge($params, $parsed);
     }
     return $params;
 }
开发者ID:dzibma,项目名称:rest-api,代码行数:13,代码来源:Input.php

示例10: prepareUrlPath

 /**
  * @param IRequest $httpRequest
  * @return string
  */
 private function prepareUrlPath(IRequest $httpRequest)
 {
     $url = $httpRequest->getUrl();
     $basePath = $url->getPath();
     $path = mb_substr($basePath, \mb_strlen($url->getBasePath()));
     if ($path !== '') {
         $path = rtrim(rawurldecode($path), '/');
     }
     return $path;
 }
开发者ID:blitzik,项目名称:CMS,代码行数:14,代码来源:UrlPath.php

示例11: send

 /**
  * @param Nette\Http\IRequest $httpRequest
  * @param Nette\Http\IResponse $httpResponse
  * @throws \Nette\Application\BadRequestException
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->contentType);
     $httpResponse->setExpiration(FALSE);
     $callback = $httpRequest->getQuery(self::$callbackName);
     if (is_null($callback)) {
         throw new \Nette\Application\BadRequestException("Invalid JSONP request.");
     }
     echo $callback . "(" . Nette\Utils\Json::encode($this->payload) . ")";
 }
开发者ID:frosty22,项目名称:ale,代码行数:15,代码来源:JsonpResponse.php

示例12: send

 /**
  * Send JSONP response to output
  * @param IRequest $httpRequest
  * @param IResponse $httpResponse
  * @throws \Drahak\Restful\InvalidArgumentException
  */
 public function send(IRequest $httpRequest, IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->contentType ? $this->contentType : 'application/javascript', 'UTF-8');
     $data = array();
     $data['response'] = $this->data;
     $data['status'] = $httpResponse->getCode();
     $data['headers'] = $httpResponse->getHeaders();
     $callback = $httpRequest->getQuery('jsonp') ? Strings::webalize($httpRequest->getQuery('jsonp'), NULL, FALSE) : '';
     echo $callback . '(' . $this->mapper->stringify($data, $this->isPrettyPrint()) . ');';
 }
开发者ID:lucien144,项目名称:Restful,代码行数:16,代码来源:JsonpResponse.php

示例13: match

 /**
  * Maps HTTP request to a Request object.
  * @return array|NULL
  */
 public function match(Nette\Http\IRequest $request)
 {
     if ($request->getUrl()->getPathInfo() !== '') {
         return NULL;
     }
     // combine with precedence: get, (post,) defaults
     $params = $request->getQuery();
     $params += $this->defaults;
     return $params;
 }
开发者ID:nette,项目名称:routing,代码行数:14,代码来源:SimpleRouter.php

示例14: createTemplate

 /**
  * @return Template
  */
 public function createTemplate(UI\Control $control = NULL)
 {
     $latte = $this->latteFactory->create();
     $template = new Template($latte);
     $presenter = $control ? $control->getPresenter(FALSE) : NULL;
     if ($control instanceof UI\Presenter) {
         $latte->setLoader(new Loader($control));
     }
     if ($latte->onCompile instanceof \Traversable) {
         $latte->onCompile = iterator_to_array($latte->onCompile);
     }
     array_unshift($latte->onCompile, function ($latte) use($control, $template) {
         $latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
         UIMacros::install($latte->getCompiler());
         if (class_exists(Nette\Bridges\FormsLatte\FormMacros::class)) {
             Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
         }
         if ($control) {
             $control->templatePrepareFilters($template);
         }
     });
     $latte->addFilter('url', 'rawurlencode');
     // back compatiblity
     foreach (['normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse'] as $name) {
         $latte->addFilter($name, 'Nette\\Utils\\Strings::' . $name);
     }
     $latte->addFilter('null', function () {
     });
     $latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
         return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit);
         // intentionally ==
     });
     if (!isset($latte->getFilters()['translate'])) {
         $latte->addFilter('translate', function (Latte\Runtime\FilterInfo $fi) {
             throw new Nette\InvalidStateException('Translator has not been set. Set translator using $template->setTranslator().');
         });
     }
     // default parameters
     $template->user = $this->user;
     $template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
     $template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
     $template->flashes = [];
     if ($control) {
         $template->control = $control;
         $template->presenter = $presenter;
         $latte->addProvider('uiControl', $control);
         $latte->addProvider('uiPresenter', $presenter);
         $latte->addProvider('snippetBridge', new Nette\Bridges\ApplicationLatte\SnippetBridge($control));
     }
     $latte->addProvider('cacheStorage', $this->cacheStorage);
     // back compatibility
     $template->_control = $control;
     $template->_presenter = $presenter;
     $template->netteCacheStorage = $this->cacheStorage;
     if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
         $id = $control->getParameterId('flash');
         $template->flashes = (array) $presenter->getFlashSession()->{$id};
     }
     return $template;
 }
开发者ID:hrach,项目名称:nette-application,代码行数:63,代码来源:TemplateFactory.php

示例15: getSignal

 /**
  * @param \Ark8\Security\Authorizators\Request $request
  * @return array
  * @throws \Nette\InvalidStateException
  */
 private function getSignal(Request $request)
 {
     $params = $request->getParameters();
     if ($this->httpRequest->isAjax()) {
         $params += $request->getPost();
     } elseif (($tmp = $request->getPost(Presenter::SIGNAL_KEY)) !== NULL) {
         $params[self::SIGNAL_KEY] = $tmp;
     }
     $signal = NULL;
     $signalReceiver = '';
     if (isset($params[Presenter::SIGNAL_KEY])) {
         $param = $params[Presenter::SIGNAL_KEY];
         $pos = strrpos($param, '-');
         if ($pos) {
             $signalReceiver = substr($param, 0, $pos);
             $signal = substr($param, $pos + 1);
         } else {
             $signalReceiver = $this->getUniqueId();
             $signal = $param;
         }
         if ($signal == NULL) {
             // intentionally ==
             $signal = NULL;
         }
     }
     return [$signal, explode('-', $signalReceiver)];
 }
开发者ID:ark8,项目名称:security,代码行数:32,代码来源:SignalAuthorizator.php


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