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


PHP IRequest::getUrl方法代码示例

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


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

示例1: generateImage

 public function generateImage(ImageRequest $request)
 {
     $width = $request->getWidth();
     $height = $request->getHeight();
     $format = $request->getFormat();
     if (!$this->validator->validate($width, $height)) {
         throw new Application\BadRequestException();
     }
     $image = NULL;
     foreach ($this->providers as $provider) {
         $image = $provider->getImage($request);
         if ($image) {
             break;
         }
     }
     if (!$image) {
         $this->httpResponse->setHeader('Content-Type', 'image/jpeg');
         $this->httpResponse->setCode(Http\IResponse::S404_NOT_FOUND);
         exit;
     }
     $destination = $this->wwwDir . '/' . $this->httpRequest->getUrl()->getRelativeUrl();
     $dirname = dirname($destination);
     if (!is_dir($dirname)) {
         $success = @mkdir($dirname, 0777, TRUE);
         if (!$success) {
             throw new Application\BadRequestException();
         }
     }
     $success = $image->save($destination, 90, $format);
     if (!$success) {
         throw new Application\BadRequestException();
     }
     $image->send();
     exit;
 }
开发者ID:kuba1999,项目名称:nette-webimages,代码行数:35,代码来源:Generator.php

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

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

示例4: getPanel

 /**
  * Renders panel.
  * @return string
  */
 public function getPanel()
 {
     ob_start();
     $request = $this->request;
     $routers = $this->routers;
     $source = $this->source;
     $url = $this->httpRequest->getUrl();
     require __DIR__ . '/templates/RoutingPanel.panel.phtml';
     return ob_get_clean();
 }
开发者ID:vol0054,项目名称:vizitky,代码行数:14,代码来源:RoutingPanel.php

示例5: checkAllowedMethods

 /**
  * Check allowed methods
  *
  * @throws BadRequestException If method is not supported but another one can be used
  */
 protected function checkAllowedMethods()
 {
     $availableMethods = $this->methods->getOptions($this->request->getUrl());
     if (!$availableMethods || in_array($this->request->method, $availableMethods)) {
         return;
     }
     $allow = implode(', ', $availableMethods);
     $this->response->setHeader('Allow', $allow);
     throw BadRequestException::methodNotSupported('Method not supported. Available methods: ' . $allow);
 }
开发者ID:lucien144,项目名称:Restful,代码行数:15,代码来源:MethodHandler.php

示例6: getResourceId

 /**
  * {@inheritdoc}
  */
 public function getResourceId()
 {
     $refUrl = $this->httpRequest->getUrl();
     $url = $this->router->constructUrl($this->request, $refUrl);
     if ($url === NULL) {
         throw new \Nette\Application\UI\InvalidLinkException();
     }
     $hostUrl = $refUrl->getHostUrl() . '/';
     if (strncmp($url, $hostUrl, strlen($hostUrl)) === 0) {
         $url = substr($url, strlen($hostUrl) - 1);
     }
     return $url;
 }
开发者ID:ark8,项目名称:security,代码行数:16,代码来源:PresenterResource.php

示例7: 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();
     require __DIR__ . '/templates/RoutingPanel.panel.phtml';
     return ob_get_clean();
 }
开发者ID:richard-ejem,项目名称:application,代码行数:17,代码来源:RoutingPanel.php

示例8: 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->getParser()->shortNoEscape = TRUE;
         $latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
         UIMacros::install($latte->getCompiler());
         if (class_exists('Nette\\Bridges\\FormsLatte\\FormMacros')) {
             Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
         }
         if ($control) {
             $control->templatePrepareFilters($template);
         }
     });
     $latte->addFilter('url', 'rawurlencode');
     // back compatiblity
     foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
         $latte->addFilter($name, 'Nette\\Utils\\Strings::' . $name);
     }
     $latte->addFilter('null', function () {
     });
     $latte->addFilter('length', function ($var) {
         return is_string($var) ? Nette\Utils\Strings::length($var) : count($var);
     });
     $latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
         return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit);
         // intentionally ==
     });
     // default parameters
     $template->control = $template->_control = $control;
     $template->presenter = $template->_presenter = $presenter;
     $template->user = $this->user;
     $template->netteHttpResponse = $this->httpResponse;
     $template->netteCacheStorage = $this->cacheStorage;
     $template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
     $template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
     $template->flashes = array();
     if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
         $id = $control->getParameterId('flash');
         $template->flashes = (array) $presenter->getFlashSession()->{$id};
     }
     return $template;
 }
开发者ID:jave007,项目名称:test,代码行数:54,代码来源:TemplateFactory.php

示例9: redirectToRequest

 /**
  * Restores request from session.
  * @param string $key
  */
 public function redirectToRequest($key)
 {
     $request = $this->requestStorage->loadRequest($key);
     if (!$request) {
         return;
     }
     $parameters = $request->getParameters();
     $parameters[Presenter::FLASH_KEY] = $this->getParameter(Presenter::FLASH_KEY);
     $parameters[RequestStorage::REQUEST_KEY] = $key;
     $request->setParameters($parameters);
     $refUrl = new Url($this->httpRequest->getUrl());
     $refUrl->setPath($this->httpRequest->getUrl()->getScriptPath());
     $url = $this->router->constructUrl($request, $refUrl);
     $this->redirectUrl($url);
 }
开发者ID:enumag,项目名称:application,代码行数:19,代码来源:RequestStoragePresenterTrait.php

示例10: send

 public function send(HttpRequest $request, HttpResponse $response)
 {
     $width = null;
     $height = null;
     $quality = null;
     try {
         $url = $request->getUrl();
         $name = Strings::after($url->getPath(), '/', -1);
         try {
             // only for case, when all images expected response from application and not from existing images
             $thumb = $this->repository->fetchThumbnail($name);
         } catch (\Imager\NotExistsException $e) {
             // thumbnail must be generate, because not exists
             $id = $url->getQueryParameter('id');
             $width = $url->getQueryParameter('width');
             $height = $url->getQueryParameter('height');
             $quality = $url->getQueryParameter('quality');
             $source = $this->repository->fetch($id);
             $thumb = $this->factory->create($source)->resize($width, $height, $quality);
             $thumb = $this->repository->save($thumb);
         }
         $response->setContentType($thumb->getMime());
         $response->setHeader('Content-Length', $thumb->getSize());
         echo $thumb->getContent();
     } catch (\Exception $e) {
         $width = $width ?: 200;
         $height = $height ?: 200;
         $this->sendError($response, $e, $width, $height);
     }
     exit(0);
 }
开发者ID:lawondyss,项目名称:imager,代码行数:31,代码来源:ImageResponse.php

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

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

示例13: process

 private function process($url, string $directory, string $parameter, array &$dependencies = []) : string
 {
     $url = new Nette\Http\Url($url);
     $time = NULL;
     if ($url->getHost() && (!$this->request || $url->getHost() !== $this->request->getUrl()->getHost())) {
         $headers = @get_headers($url, TRUE);
         if (is_array($headers) && isset($headers['Last-Modified'])) {
             $time = (new DateTime($headers['Last-Modified']))->getTimestamp();
         }
     } elseif (is_file($filename = implode(DIRECTORY_SEPARATOR, [rtrim($directory, '\\/'), ltrim($url->getPath(), '\\/')]))) {
         $time = filemtime($filename);
         unset($dependencies[Nette\Caching\Cache::EXPIRE]);
         $dependencies[Nette\Caching\Cache::FILES] = $filename;
     }
     $url->setQueryParameter($parameter, $time ?: ($this->time ?: ($this->time = time())));
     return preg_replace($pattern = '#^(\\+|/+)#', preg_match($pattern, $url->getPath()) ? DIRECTORY_SEPARATOR : NULL, $url);
 }
开发者ID:vitkutny,项目名称:version,代码行数:17,代码来源:Filter.php

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

示例15: getLastPageUrl

 /**
  * Get last page URL
  * @param Paginator $paginator
  * @return Link
  */
 private function getLastPageUrl(Paginator $paginator)
 {
     $url = clone $this->request->getUrl();
     parse_str($url->getQuery(), $query);
     $query['offset'] = $paginator->getLastPage() * $paginator->getItemsPerPage() - $paginator->getItemsPerPage();
     $query['limit'] = $paginator->getItemsPerPage();
     $url->appendQuery($query);
     return new Link($url, Link::LAST);
 }
开发者ID:lucien144,项目名称:Restful,代码行数:14,代码来源:ResponseFactory.php


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