本文整理汇总了PHP中TYPO3\Flow\Http\Request::getBaseUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getBaseUri方法的具体用法?PHP Request::getBaseUri怎么用?PHP Request::getBaseUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Http\Request
的用法示例。
在下文中一共展示了Request::getBaseUri方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendRedirectHeaders
/**
* @param HttpRequest $request
* @param Redirection $redirection
* @return void
*/
protected function sendRedirectHeaders(HttpRequest $request, Redirection $redirection)
{
if (headers_sent()) {
return;
}
$sourceUriPath = $redirection->getRequestPattern();
$targetUriPath = $redirection->getTarget();
if (strpos($sourceUriPath, '%') !== false) {
$sourceUriPath = preg_quote($sourceUriPath, '/');
$sourceUriPath = str_replace('%', '(.*)', $sourceUriPath);
$targetUriPath = preg_replace('/' . $sourceUriPath . '/', $redirection->getTarget(), $request->getRelativePath());
}
header($redirection->getStatusLine());
header('Location: ' . $request->getBaseUri() . $targetUriPath);
}
示例2: startAuthentication
/**
* Starts the authentication: Redirect to login page
*
* @param \TYPO3\Flow\Http\Request $request The current request
* @param \TYPO3\Flow\Http\Response $response The current response
* @return void
* @throws MissingConfigurationException
*/
public function startAuthentication(Request $request, Response $response)
{
if (isset($this->options['routeValues'])) {
$routeValues = $this->options['routeValues'];
if (!is_array($routeValues)) {
throw new MissingConfigurationException(sprintf('The configuration for the WebRedirect authentication entry point is incorrect. "routeValues" must be an array, got "%s".', gettype($routeValues)), 1345040415);
}
$actionRequest = new ActionRequest($request);
$this->uriBuilder->setRequest($actionRequest);
$actionName = $this->extractRouteValue($routeValues, '@action');
$controllerName = $this->extractRouteValue($routeValues, '@controller');
$packageKey = $this->extractRouteValue($routeValues, '@package');
$subPackageKey = $this->extractRouteValue($routeValues, '@subpackage');
$uri = $this->uriBuilder->setCreateAbsoluteUri(true)->uriFor($actionName, $routeValues, $controllerName, $packageKey, $subPackageKey);
} elseif (isset($this->options['uri'])) {
$uri = strpos($this->options['uri'], '://') !== false ? $this->options['uri'] : $request->getBaseUri() . $this->options['uri'];
} else {
throw new MissingConfigurationException('The configuration for the WebRedirect authentication entry point is incorrect or missing. You need to specify either the target "uri" or "routeValues".', 1237282583);
}
$response->setContent(sprintf('<html><head><meta http-equiv="refresh" content="0;url=%s"/></head></html>', htmlentities($uri, ENT_QUOTES, 'utf-8')));
$response->setStatus(303);
$response->setHeader('Location', $uri);
}
示例3: getBaseUriReturnsThePresetBaseUriIfItHasBeenSet
/**
* @test
*/
public function getBaseUriReturnsThePresetBaseUriIfItHasBeenSet()
{
$server = array('HTTP_HOST' => 'dev.blog.rob', 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/foo/bar', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php');
$request = new Request(array(), array(), array(), $server);
$baseUri = new \TYPO3\Flow\Http\Uri('http://prod.blog.rob/');
$request->setBaseUri($baseUri);
$this->assertEquals('http://prod.blog.rob/', (string) $request->getBaseUri());
}
示例4: getCrawler
/**
* Returns the DOM crawler which can be used to interact with the web page
* structure, submit forms, click links or fetch specific parts of the
* website's contents.
*
* The returned DOM crawler is bound to the response of the last executed
* request.
*
* @return \Symfony\Component\DomCrawler\Crawler
* @api
*/
public function getCrawler()
{
$crawler = new Crawler(null, $this->lastRequest->getBaseUri());
$crawler->addContent($this->lastResponse->getContent(), $this->lastResponse->getHeader('Content-Type'));
return $crawler;
}