本文整理汇总了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;
}
示例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));
}
示例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);
}