Created
March 10, 2014 15:08
-
-
Save matej21/9466767 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Nette\Http\Request; | |
class RefUrlFactory extends Object | |
{ | |
/** @var \Nette\Http\Url */ | |
protected $fallbackUrl; | |
/** @var \Nette\Http\Request */ | |
protected $httpRequest; | |
/** | |
* @param Url $fallbackUrl | |
* @param Request $httpRequest | |
*/ | |
public function __construct($fallbackUrl, Request $httpRequest) | |
{ | |
$this->fallbackUrl = new \Nette\Http\Url($fallbackUrl); | |
$this->httpRequest = $httpRequest; | |
} | |
/** | |
* @return \Nette\Http\Url|\Nette\Http\UrlScript | |
*/ | |
public function create() | |
{ | |
$url = $this->httpRequest->getUrl(); | |
if (!$url->getHost()) { | |
$url = $this->fallbackUrl; | |
} | |
return $url; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment