本文整理汇总了PHP中TYPO3\Flow\Http\Request类的典型用法代码示例。如果您正苦于以下问题:PHP Request类的具体用法?PHP Request怎么用?PHP Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findOneByRequest
/**
* @param HttpRequest $request
* @return Redirection
*/
public function findOneByRequest(HttpRequest $request)
{
$requestPath = preg_replace('/(\\\\|%|_)/', '\\\\$1', $request->getRelativePath());
$query = $this->createQuery();
$query->getQueryBuilder()->where(':requestPath LIKE e.requestPattern')->setParameter('requestPath', $requestPath);
return $query->execute()->getFirst();
}
示例2: __construct
/**
*
*/
public function __construct($message, $code, \TYPO3\Flow\Http\Response $response, \TYPO3\Flow\Http\Request $request = NULL, \Exception $previous = NULL)
{
$this->response = $response;
$this->request = $request;
if ($request !== NULL) {
$message = sprintf("[%s %s]: %s\n\nRequest data: %s", $request->getMethod(), $request->getUri(), $message . '; Response body: ' . $response->getContent(), $request->getContent());
}
parent::__construct($message, $code, $previous);
}
示例3: extractWidgetContext
/**
* Extracts the WidgetContext from the given $httpRequest.
* If the request contains an argument "__widgetId" the context is fetched from the session (AjaxWidgetContextHolder).
* Otherwise the argument "__widgetContext" is expected to contain the serialized WidgetContext (protected by a HMAC suffix)
*
* @param Request $httpRequest
* @return WidgetContext
*/
protected function extractWidgetContext(Request $httpRequest)
{
if ($httpRequest->hasArgument('__widgetId')) {
return $this->ajaxWidgetContextHolder->get($httpRequest->getArgument('__widgetId'));
} elseif ($httpRequest->hasArgument('__widgetContext')) {
$serializedWidgetContextWithHmac = $httpRequest->getArgument('__widgetContext');
$serializedWidgetContext = $this->hashService->validateAndStripHmac($serializedWidgetContextWithHmac);
return unserialize(base64_decode($serializedWidgetContext));
}
return null;
}
示例4: createRequest
/**
* Creates a PSR-7 compatible request
*
* @param \TYPO3\Flow\Http\Request $nativeRequest Flow request object
* @param array $files List of uploaded files like in $_FILES
* @param array $query List of uploaded files like in $_GET
* @param array $post List of uploaded files like in $_POST
* @param array $cookies List of uploaded files like in $_COOKIES
* @param array $server List of uploaded files like in $_SERVER
* @return \Psr\Http\Message\ServerRequestInterface PSR-7 request object
*/
protected function createRequest(\TYPO3\Flow\Http\Request $nativeRequest, array $files, array $query, array $post, array $cookies, array $server)
{
$server = ServerRequestFactory::normalizeServer($server);
$files = ServerRequestFactory::normalizeFiles($files);
$headers = $nativeRequest->getHeaders()->getAll();
$uri = (string) $nativeRequest->getUri();
$method = $nativeRequest->getMethod();
$body = new Stream('php://temp', 'wb+');
$body->write($nativeRequest->getContent());
return new ServerRequest($server, $files, $uri, $method, $body, $headers, $cookies, $query, $post);
}
示例5: setUp
public function setUp()
{
$this->fileSystemTarget = new FileSystemTarget('test');
$this->mockBootstrap = $this->getMockBuilder(Bootstrap::class)->disableOriginalConstructor()->getMock();
$this->mockRequestHandler = $this->getMockBuilder(HttpRequestHandlerInterface::class)->getMock();
$this->mockHttpRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
$this->mockHttpRequest->expects($this->any())->method('getBaseUri')->will($this->returnValue(new Uri('http://detected/base/uri/')));
$this->mockRequestHandler->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
$this->mockBootstrap->expects($this->any())->method('getActiveRequestHandler')->will($this->returnValue($this->mockRequestHandler));
$this->inject($this->fileSystemTarget, 'bootstrap', $this->mockBootstrap);
}
示例6: startAuthentication
/**
* Starts the authentication by redirecting to the SSO endpoint
*
* The redirect includes the callback URI (the original URI from the given request)
* the client identifier and a signature of the arguments with the client private key.
*
* @param \TYPO3\Flow\Http\Request $request The current request
* @param \TYPO3\Flow\Http\Response $response The current response
* @return void
*/
public function startAuthentication(Request $request, Response $response)
{
$callbackUri = $request->getUri();
if (!isset($this->options['server'])) {
throw new Exception('Missing "server" option for SingleSignOnRedirect entry point. Please specifiy one using the entryPointOptions setting.', 1351690358);
}
$ssoServer = $this->ssoServerFactory->create($this->options['server']);
$ssoClient = $this->ssoClientFactory->create();
$redirectUri = $ssoServer->buildAuthenticationEndpointUri($ssoClient, $callbackUri);
$response->setStatus(303);
$response->setHeader('Location', $redirectUri);
}
示例7: 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);
}
示例8: __construct
/**
* Construct
*/
public function __construct()
{
$httpRequest = \TYPO3\Flow\Http\Request::createFromEnvironment();
$actionRequest = new \TYPO3\Flow\Mvc\ActionRequest($httpRequest);
$this->uriBuilder = new \TYPO3\Flow\Mvc\Routing\UriBuilder();
$this->uriBuilder->setRequest($actionRequest);
}
示例9: setUp
/**
* @return void
*/
public function setUp()
{
$this->viewHelperVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
$this->viewHelperVariableContainer->expects($this->any())->method('exists')->will($this->returnCallback(array($this, 'viewHelperVariableContainerExistsCallback')));
$this->viewHelperVariableContainer->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'viewHelperVariableContainerGetCallback')));
$this->templateVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer');
$this->uriBuilder = $this->getMock('TYPO3\\Flow\\Mvc\\Routing\\UriBuilder');
$this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
// BACKPORTER TOKEN #1
$httpRequest = \TYPO3\Flow\Http\Request::create(new \TYPO3\Flow\Http\Uri('http://localhost/foo'));
$this->request = $this->getMock('TYPO3\\Flow\\Mvc\\ActionRequest', array(), array($httpRequest));
$this->request->expects($this->any())->method('isMainRequest')->will($this->returnValue(TRUE));
$this->controllerContext = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
$this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
$this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
$this->tagBuilder = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TagBuilder');
$this->arguments = array();
$this->renderingContext = new \TYPO3\Fluid\Core\Rendering\RenderingContext();
$this->renderingContext->injectTemplateVariableContainer($this->templateVariableContainer);
$this->renderingContext->injectViewHelperVariableContainer($this->viewHelperVariableContainer);
$this->renderingContext->setControllerContext($this->controllerContext);
}
示例10: updateCredentialsIgnoresAnythingOtherThanPostRequests
/**
* @test
*/
public function updateCredentialsIgnoresAnythingOtherThanPostRequests()
{
$arguments = array();
$arguments['__authentication']['TYPO3']['Flow']['Security']['Authentication']['Token']['PasswordToken']['password'] = 'verysecurepassword';
$this->mockHttpRequest->expects($this->atLeastOnce())->method('getMethod')->will($this->returnValue('POST'));
$this->mockActionRequest->expects($this->atLeastOnce())->method('getInternalArguments')->will($this->returnValue($arguments));
$this->token->updateCredentials($this->mockActionRequest);
$this->assertEquals(array('password' => 'verysecurepassword'), $this->token->getCredentials());
$secondToken = new PasswordToken();
$secondMockActionRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
$secondMockHttpRequest = $this->getMockBuilder(\TYPO3\Flow\Http\Request::class)->disableOriginalConstructor()->getMock();
$secondMockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($secondMockHttpRequest));
$secondMockHttpRequest->expects($this->atLeastOnce())->method('getMethod')->will($this->returnValue('GET'));
$secondToken->updateCredentials($secondMockActionRequest);
$this->assertEquals(array('password' => ''), $secondToken->getCredentials());
}
示例11: handleRequest
/**
* Handles a HTTP request
*
* @return void
*/
public function handleRequest()
{
// Create the request very early so the Resource Management has a chance to grab it:
$this->request = \TYPO3\Flow\Http\Request::createFromEnvironment();
$this->response = new \TYPO3\Flow\Http\Response();
$this->boot();
$this->resolveDependencies();
$this->request->injectSettings($this->settings);
$this->addDebugToolbarRoutes();
$this->router->setRoutesConfiguration($this->routesConfiguration);
$actionRequest = $this->router->route($this->request);
$this->securityContext->setRequest($actionRequest);
$this->dispatcher->dispatch($actionRequest, $this->response);
$this->response->makeStandardsCompliant($this->request);
\Debug\Toolbar\Service\DataStorage::add('Request:Requests', $actionRequest);
\Debug\Toolbar\Service\DataStorage::add('Request:Responses', $this->response);
\Debug\Toolbar\Toolbar\View::handleRedirects($this->request, $this->response);
$this->emitAboutToRenderDebugToolbar();
\Debug\Toolbar\Service\DataStorage::set('Modules', \Debug\Toolbar\Service\Collector::getModules());
if ($actionRequest->getFormat() === 'html') {
echo \Debug\Toolbar\Toolbar\View::attachToolbar($this->response->getContent());
} else {
echo $this->response->getContent();
}
$this->bootstrap->shutdown('Runtime');
$this->exit->__invoke();
\Debug\Toolbar\Service\DataStorage::save();
}
示例12: dispatchContinuesWithNextRequestFoundInAForwardException
/**
* @test
*/
public function dispatchContinuesWithNextRequestFoundInAForwardException()
{
$httpRequest = Request::create(new Uri('http://localhost'));
$httpResponse = new Response();
$mainRequest = $httpRequest->createActionRequest();
$subRequest = new ActionRequest($mainRequest);
$nextRequest = $httpRequest->createActionRequest();
$mainRequest->setDispatched(TRUE);
$mainRequest->setControllerSubPackageKey('main');
$subRequest->setControllerSubPackageKey('sub');
$nextRequest->setControllerSubPackageKey('next');
$mockController = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerInterface', array('processRequest'));
$mockController->expects($this->at(0))->method('processRequest')->will($this->returnCallback(function (ActionRequest $request) use($nextRequest) {
$request->setDispatched(TRUE);
$forwardException = new ForwardException();
$forwardException->setNextRequest($nextRequest);
throw $forwardException;
}));
$mockController->expects($this->at(1))->method('processRequest')->will($this->returnCallback(function (ActionRequest $request) use($nextRequest) {
// NOTE: PhpUnit creates a clone of $nextRequest, thus $request is not the same instance as expected.
if ($request == $nextRequest) {
$nextRequest->setDispatched(TRUE);
}
}));
$dispatcher = $this->getMock('TYPO3\\Flow\\Mvc\\Dispatcher', array('resolveController', 'emitAfterControllerInvocation'), array(), '', FALSE);
$dispatcher->expects($this->any())->method('resolveController')->will($this->returnValue($mockController));
$dispatcher->dispatch($subRequest, $httpResponse);
}
示例13: requestMatchingBasicallyWorks
/**
* @dataProvider uriAndHostPatterns
* @test
*/
public function requestMatchingBasicallyWorks($uri, $pattern, $expected, $message)
{
$request = Request::create(new \TYPO3\Flow\Http\Uri($uri))->createActionRequest();
$requestPattern = new \TYPO3\Flow\Security\RequestPattern\Host();
$requestPattern->setPattern($pattern);
$this->assertEquals($expected, $requestPattern->matchRequest($request), $message);
}
示例14: updateCredentialsSetsTheCorrectAuthenticationStatusIfNoCredentialsArrived
/**
* @test
*/
public function updateCredentialsSetsTheCorrectAuthenticationStatusIfNoCredentialsArrived()
{
$request = Request::create(new Uri('http://foo.com'));
$actionRequest = $request->createActionRequest();
$token = new UsernamePasswordHttpBasic();
$token->updateCredentials($actionRequest);
$this->assertSame(TokenInterface::NO_CREDENTIALS_GIVEN, $token->getAuthenticationStatus());
}
示例15: handleMergesInternalArgumentsWithRoutingMatchResults
/**
* @test
*/
public function handleMergesInternalArgumentsWithRoutingMatchResults()
{
$this->mockHttpRequest->expects($this->any())->method('getArguments')->will($this->returnValue(array('__internalArgument1' => 'request', '__internalArgument2' => 'request', '__internalArgument3' => 'request')));
$this->mockPropertyMapper->expects($this->any())->method('convert')->with('', 'array', $this->mockPropertyMappingConfiguration)->will($this->returnValue(array('__internalArgument2' => 'requestBody', '__internalArgument3' => 'requestBody')));
$this->mockComponentContext->expects($this->atLeastOnce())->method('getParameter')->with('TYPO3\\Flow\\Mvc\\Routing\\RoutingComponent', 'matchResults')->will($this->returnValue(array('__internalArgument3' => 'routing')));
$this->mockActionRequest->expects($this->once())->method('setArguments')->with(array('__internalArgument1' => 'request', '__internalArgument2' => 'requestBody', '__internalArgument3' => 'routing'));
$this->dispatchComponent->handle($this->mockComponentContext);
}