Considers the environment information found in PHP's superglobals and Flow's
environment configuration and creates a new instance of this Request class
matching that data.
public static createFromEnvironment ( ) : |
||
return |
/** * @return ControllerContext */ protected function createControllerContextFromEnvironment() { $httpRequest = Request::createFromEnvironment(); /** @var ActionRequest $request */ $request = new ActionRequest($httpRequest); $uriBuilder = new UriBuilder(); $uriBuilder->setRequest($request); return new ControllerContext($request, new Response(), new Arguments(array()), $uriBuilder); }
/** * @test * @backupGlobals disabled */ public function createFromEnvironmentWithEmptyServerVariableWorks() { $server = $_SERVER; $_GET = []; $_POST = []; $_COOKIE = []; $_FILES = []; $_SERVER = []; $request = Request::createFromEnvironment(); $this->assertEquals('http://localhost/', (string) $request->getUri()); $_SERVER = $server; }
/** * Helper to build a Fusion view object * * @return FusionView */ protected function buildView() { $view = new FusionView(); $httpRequest = Request::createFromEnvironment(); $request = $httpRequest->createActionRequest(); $uriBuilder = new UriBuilder(); $uriBuilder->setRequest($request); $this->controllerContext = new ControllerContext($request, new Response(), new Arguments(array()), $uriBuilder); $view->setControllerContext($this->controllerContext); $view->disableFallbackView(); $view->setPackageKey('Neos.Fusion'); $view->setTypoScriptPathPattern(__DIR__ . '/Fixtures/TypoScript'); $view->assign('fixtureDirectory', __DIR__ . '/Fixtures/'); return $view; }
/** * 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 = Request::createFromEnvironment(); $this->response = new Response(); $this->checkBasicRequirementsAndDisplayLoadingScreen(); $this->boot(); $this->resolveDependencies(); if (isset($this->settings['http']['baseUri'])) { $this->request->setBaseUri(new Uri($this->settings['http']['baseUri'])); } $componentContext = new ComponentContext($this->request, $this->response); $this->baseComponentChain->handle($componentContext); $this->response->send(); $this->bootstrap->shutdown('Runtime'); $this->exit->__invoke(); }
/** * Sets up security test requirements * * Security is based on action requests so we need a working route for the TestingProvider. * * @return void */ protected function setupSecurity() { if ($this->securityInitialized === true) { return; } $this->privilegeManager = $this->objectManager->get(PrivilegeManagerInterface::class); $this->privilegeManager->setOverrideDecision(null); $this->policyService = $this->objectManager->get(PolicyService::class); $this->authenticationManager = $this->objectManager->get(AuthenticationProviderManager::class); $this->testingProvider = $this->objectManager->get(TestingProvider::class); $this->testingProvider->setName('TestingProvider'); $this->securityContext = $this->objectManager->get(Security\Context::class); $this->securityContext->clearContext(); $httpRequest = Request::createFromEnvironment(); $this->mockActionRequest = new ActionRequest($httpRequest); $this->mockActionRequest->setControllerObjectName(AuthenticationController::class); $this->securityContext->setRequest($this->mockActionRequest); $this->securityInitialized = true; }
/** * Creates an UriBuilder instance for the current request * * @return UriBuilder */ protected function getUriBuilder() { if ($this->uriBuilder === null) { $httpRequest = Request::createFromEnvironment(); $actionRequest = new ActionRequest($httpRequest); $this->uriBuilder = new UriBuilder(); $this->uriBuilder->setRequest($actionRequest); $this->uriBuilder->setFormat('html')->setCreateAbsoluteUri(false); } return $this->uriBuilder; }
/** * Prepares a Fluid view for rendering the custom error page. * * @param object $exception \Exception or \Throwable * @param array $renderingOptions Rendering options as defined in the settings * @return ViewInterface */ protected function buildView($exception, array $renderingOptions) { $statusCode = 500; $referenceCode = null; if ($exception instanceof FlowException) { $statusCode = $exception->getStatusCode(); $referenceCode = $exception->getReferenceCode(); } $statusMessage = Response::getStatusMessageByCode($statusCode); $viewClassName = $renderingOptions['viewClassName']; /** @var ViewInterface $view */ $view = $viewClassName::createWithOptions($renderingOptions['viewOptions']); $view = $this->applyLegacyViewOptions($view, $renderingOptions); $httpRequest = Request::createFromEnvironment(); $request = new ActionRequest($httpRequest); $request->setControllerPackageKey('Neos.Flow'); $uriBuilder = new UriBuilder(); $uriBuilder->setRequest($request); $view->setControllerContext(new ControllerContext($request, new Response(), new Arguments([]), $uriBuilder)); if (isset($renderingOptions['variables'])) { $view->assignMultiple($renderingOptions['variables']); } $view->assignMultiple(['exception' => $exception, 'renderingOptions' => $renderingOptions, 'statusCode' => $statusCode, 'statusMessage' => $statusMessage, 'referenceCode' => $referenceCode]); return $view; }
/** * Internal getter to ensure an existing ComponentContext. * * @return ComponentContext */ protected function getComponentContext() { if ($this->componentContext === null) { $this->componentContext = new ComponentContext(Http\Request::createFromEnvironment(), new Http\Response()); } return $this->componentContext; }
/** * Handles a HTTP request * * @return void */ public function handleRequest() { // Create the request very early so the ResourceManagement has a chance to grab it: $request = Request::createFromEnvironment(); $response = new Response(); $this->componentContext = new ComponentContext($request, $response); $this->boot(); $this->resolveDependencies(); $this->addPoweredByHeader($response); if (isset($this->settings['http']['baseUri'])) { $request->setBaseUri(new Uri($this->settings['http']['baseUri'])); } $this->baseComponentChain->handle($this->componentContext); $response = $this->baseComponentChain->getResponse(); $response->send(); $this->bootstrap->shutdown(Bootstrap::RUNLEVEL_RUNTIME); $this->exit->__invoke(); }
/** * Initiates the StandaloneView by creating the required ControllerContext * * @return void */ public function initializeObject() { if ($this->request === null) { $httpRequest = Request::createFromEnvironment(); $this->request = new ActionRequest($httpRequest); } $uriBuilder = new UriBuilder(); $uriBuilder->setRequest($this->request); $this->setControllerContext(new ControllerContext($this->request, new Response(), new Arguments(array()), $uriBuilder)); }