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


PHP Url::getHostUrl方法代码示例

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


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

示例1: createRequest


//.........这里部分代码省略.........
         // counterpart of IStatePersistent
         if ($args && array_intersect_key($args, $reflection->getPersistentParams())) {
             $component->saveState($args);
         }
         if ($args && $component !== $this) {
             $prefix = $component->getUniqueId() . self::NAME_SEPARATOR;
             foreach ($args as $key => $val) {
                 unset($args[$key]);
                 $args[$prefix . $key] = $val;
             }
         }
     }
     // PROCESS ARGUMENTS
     if (is_subclass_of($presenterClass, __CLASS__)) {
         if ($action === '') {
             $action = self::DEFAULT_ACTION;
         }
         $current = ($action === '*' || strcasecmp($action, $this->action) === 0) && $presenterClass === get_class($this);
         $reflection = new ComponentReflection($presenterClass);
         // counterpart of run() & tryCall()
         $method = $presenterClass::formatActionMethod($action);
         if (!$reflection->hasCallableMethod($method)) {
             $method = $presenterClass::formatRenderMethod($action);
             if (!$reflection->hasCallableMethod($method)) {
                 $method = NULL;
             }
         }
         // convert indexed parameters to named
         if ($method === NULL) {
             if (array_key_exists(0, $args)) {
                 throw new InvalidLinkException("Unable to pass parameters to action '{$presenter}:{$action}', missing corresponding method.");
             }
         } else {
             self::argsToParams($presenterClass, $method, $args, $destination === 'this' ? $this->params : [], $missing);
         }
         // counterpart of IStatePersistent
         if ($args && array_intersect_key($args, $reflection->getPersistentParams())) {
             $this->saveState($args, $reflection);
         }
         if ($mode === 'redirect') {
             $this->saveGlobalState();
         }
         $globalState = $this->getGlobalState($destination === 'this' ? NULL : $presenterClass);
         if ($current && $args) {
             $tmp = $globalState + $this->params;
             foreach ($args as $key => $val) {
                 if (http_build_query([$val]) !== (isset($tmp[$key]) ? http_build_query([$tmp[$key]]) : '')) {
                     $current = FALSE;
                     break;
                 }
             }
         }
         $args += $globalState;
     }
     if ($mode !== 'test' && !empty($missing)) {
         foreach ($missing as $rp) {
             if (!array_key_exists($rp->getName(), $args)) {
                 throw new InvalidLinkException("Missing parameter \${$rp->getName()} required by {$rp->getDeclaringClass()->getName()}::{$rp->getDeclaringFunction()->getName()}()");
             }
         }
     }
     // ADD ACTION & SIGNAL & FLASH
     if ($action) {
         $args[self::ACTION_KEY] = $action;
     }
     if (!empty($signal)) {
         $args[self::SIGNAL_KEY] = $component->getParameterId($signal);
         $current = $current && $args[self::SIGNAL_KEY] === $this->getParameter(self::SIGNAL_KEY);
     }
     if (($mode === 'redirect' || $mode === 'forward') && $this->hasFlashSession()) {
         $args[self::FLASH_KEY] = $this->getFlashKey();
     }
     $this->lastCreatedRequest = new Application\Request($presenter, Application\Request::FORWARD, $args, [], []);
     $this->lastCreatedRequestFlag = ['current' => $current];
     if ($mode === 'forward' || $mode === 'test') {
         return;
     }
     // CONSTRUCT URL
     if ($this->refUrlCache === NULL) {
         $this->refUrlCache = new Http\Url($this->httpRequest->getUrl());
         $this->refUrlCache->setPath($this->httpRequest->getUrl()->getScriptPath());
     }
     if (!$this->router) {
         throw new Nette\InvalidStateException('Unable to generate URL, service Router has not been set.');
     }
     $url = $this->router->constructUrl($this->lastCreatedRequest, $this->refUrlCache);
     if ($url === NULL) {
         unset($args[self::ACTION_KEY]);
         $params = urldecode(http_build_query($args, NULL, ', '));
         throw new InvalidLinkException("No route for {$presenter}:{$action}({$params})");
     }
     // make URL relative if possible
     if ($mode === 'link' && $scheme === FALSE && !$this->absoluteUrls) {
         $hostUrl = $this->refUrlCache->getHostUrl() . '/';
         if (strncmp($url, $hostUrl, strlen($hostUrl)) === 0) {
             $url = substr($url, strlen($hostUrl) - 1);
         }
     }
     return $url . $fragment;
 }
开发者ID:hrach,项目名称:nette-application,代码行数:101,代码来源:Presenter.php

示例2: getSignatureBaseString

 /**
  * Returns the base string of this request
  *
  * The base string defined as the method, the url
  * and the parameters (normalized), each urlencoded
  * and the concated with &
  */
 public function getSignatureBaseString()
 {
     $parts = [$this->method, $this->url->getHostUrl() . $this->url->getPath(), $this->getSignableParameters()];
     return implode('&', OAuth\Utils\Url::urlEncodeRFC3986($parts));
 }
开发者ID:pkristian,项目名称:flickrlickr,代码行数:12,代码来源:Request.php

示例3: create

 /**
  * @param \Nette\Http\Session
  * @param \Nette\Http\Url
  * @param string
  * @param string
  * @return AddonManageFacade
  */
 public static function create(Session $session, Url $currentUrl, $uploadDir, $uploadUri)
 {
     $url = $currentUrl->getHostUrl() . rtrim($currentUrl->getBasePath(), '/') . $uploadUri;
     return new static($session, $uploadDir, $url);
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:12,代码来源:AddonManageFacade.php


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