本文整理汇总了PHP中TYPO3\Flow\Http\Request::createFromEnvironment方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::createFromEnvironment方法的具体用法?PHP Request::createFromEnvironment怎么用?PHP Request::createFromEnvironment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Http\Request
的用法示例。
在下文中一共展示了Request::createFromEnvironment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: handleRequest
/**
* Handles a raw ExtDirect request and sends the response.
*
* @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->flowSettings);
$this->router->setRoutesConfiguration($this->routesConfiguration);
try {
$extDirectRequest = $this->buildJsonRequest($this->request);
$results = array();
foreach ($extDirectRequest->getTransactions() as $transaction) {
$requestOfCurrentTransaction = $transaction->buildRequest($extDirectRequest);
$responseOfCurrentTransaction = $transaction->buildResponse();
try {
$this->securityContext->setRequest($requestOfCurrentTransaction);
$this->securityContext->initialize();
$this->dispatcher->dispatch($requestOfCurrentTransaction, $responseOfCurrentTransaction);
$results[] = array('type' => 'rpc', 'tid' => $transaction->getTid(), 'action' => $transaction->getAction(), 'method' => $transaction->getMethod(), 'result' => $responseOfCurrentTransaction->getResult());
} catch (\Exception $exception) {
$results[] = $this->handleException($exception, $transaction->getTid());
}
}
$this->prepareResponse($results, $extDirectRequest);
} catch (InvalidExtDirectRequestException $exception) {
$results[] = $this->handleException($exception);
$this->prepareResponse($results);
}
$this->response->makeStandardsCompliant($this->request);
$this->response->send();
$this->bootstrap->shutdown('Runtime');
$this->exit->__invoke();
}
示例3: __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);
}
示例4: createControllerContextFromEnvironment
/**
* @return ControllerContext
*/
protected function createControllerContextFromEnvironment()
{
$httpRequest = Request::createFromEnvironment();
/** @var ActionRequest $request */
$request = $httpRequest->createActionRequest();
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($request);
return new ControllerContext($request, new Response(), new Arguments(array()), $uriBuilder);
}
示例5: getRequestMediaType
/**
* @return null|string
*/
protected function getRequestMediaType()
{
if (PHP_SAPI !== 'cli' && ($httpRequest = \TYPO3\Flow\Http\Request::createFromEnvironment())) {
if ($httpRequest !== NULL) {
return $httpRequest->getNegotiatedMediaType($this->supportedMediaTypes);
}
}
return NULL;
}
示例6: createFromEnvironmentWithEmptyServerVariableWorks
/**
* @test
*/
public function createFromEnvironmentWithEmptyServerVariableWorks()
{
$_GET = array();
$_POST = array();
$_COOKIE = array();
$_FILES = array();
$_SERVER = array();
$request = Request::createFromEnvironment();
$this->assertEquals('http://localhost/', (string) $request->getUri());
}
示例7: initializeObject
/**
* Initiates the StandaloneView by creating the required ControllerContext
*
* @return void
*/
public function initializeObject()
{
if ($this->request === null) {
$httpRequest = Request::createFromEnvironment();
$this->request = $this->objectManager->get(\TYPO3\Flow\Mvc\ActionRequest::class, $httpRequest);
}
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($this->request);
$this->setControllerContext(new ControllerContext($this->request, new Response(), new Arguments(array()), $uriBuilder));
}
示例8: buildView
/**
* Helper to build a TypoScript view object
*
* @return TypoScriptView
*/
protected function buildView()
{
$view = new TypoScriptView();
$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('TYPO3.TypoScript');
$view->setTypoScriptPathPattern(__DIR__ . '/Fixtures/TypoScript');
$view->assign('fixtureDirectory', __DIR__ . '/Fixtures/');
return $view;
}
示例9: sendNotificationMail
/**
* @param Account $account
* @return void
*/
protected function sendNotificationMail(Account $account)
{
$notificationMailSettings = $this->settings['notificationMail'];
if (!$notificationMailSettings['to']) {
return;
}
$httpRequest = Request::createFromEnvironment();
$failedAttemptsThreshold = $this->settings['failedAttemptsThreshold'];
$time = (new \DateTime())->format('Y-m-d H:i');
$replacePlaceholders = function ($string) use($account, $httpRequest, $failedAttemptsThreshold, $time) {
return str_replace(['{domain}', '{ip}', '{userAgent}', '{accountIdentifier}', '{failedAttemptsThreshold}', '{time}'], [$httpRequest->getUri()->getHost(), $httpRequest->getClientIpAddress(), $_SERVER['HTTP_USER_AGENT'], $account->getAccountIdentifier(), $failedAttemptsThreshold, $time], $string);
};
$mail = new Message();
$mail->setFrom($replacePlaceholders($notificationMailSettings['from']['email']), $replacePlaceholders($notificationMailSettings['from']['name']))->setTo($notificationMailSettings['to'])->setSubject($replacePlaceholders($notificationMailSettings['subject']))->setBody($replacePlaceholders($notificationMailSettings['message']))->send();
}
示例10: 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 = 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();
}
示例11: importSiteFromTemplate
/**
* @param string $sitePackage
* @param string $siteName
* @param string $baseDomain
* @return Site
*/
public function importSiteFromTemplate($sitePackage, $siteName, $baseDomain = '')
{
if (empty($baseDomain)) {
$request = Request::createFromEnvironment();
$baseDomain = $request->getBaseUri()->getHost();
}
$siteTemplate = new StandaloneView();
$siteTemplate->setTemplatePathAndFilename(FLOW_PATH_PACKAGES . 'Sites/' . $sitePackage . '/Resources/Private/Templates/Content/Sites.xml');
$siteTemplate->assignMultiple(['siteName' => $siteName, 'siteNodeName' => \TYPO3\TYPO3CR\Utility::renderValidNodeName($siteName), 'packageKey' => $sitePackage]);
$generatedSiteImportXmlContent = $siteTemplate->render();
$dataTemporaryPath = $this->environment->getPathToTemporaryDirectory();
$temporarySiteXml = $dataTemporaryPath . uniqid($siteName) . '.xml';
file_put_contents($temporarySiteXml, $generatedSiteImportXmlContent);
$site = $this->siteImportService->importFromFile($temporarySiteXml);
$domain = new Domain();
$domain->setActive(true);
$domain->setSite($site);
$domain->setHostPattern(\TYPO3\TYPO3CR\Utility::renderValidNodeName($siteName) . '.' . $baseDomain);
$this->domainRepository->add($domain);
return $site;
}
示例12: setupSecurity
/**
* 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(\TYPO3\Flow\Security\Authorization\PrivilegeManagerInterface::class);
$this->privilegeManager->setOverrideDecision(null);
$this->policyService = $this->objectManager->get(\TYPO3\Flow\Security\Policy\PolicyService::class);
$this->authenticationManager = $this->objectManager->get(\TYPO3\Flow\Security\Authentication\AuthenticationProviderManager::class);
$this->testingProvider = $this->objectManager->get(\TYPO3\Flow\Security\Authentication\Provider\TestingProvider::class);
$this->testingProvider->setName('TestingProvider');
$this->securityContext = $this->objectManager->get(\TYPO3\Flow\Security\Context::class);
$this->securityContext->clearContext();
$httpRequest = Request::createFromEnvironment();
$this->mockActionRequest = new ActionRequest($httpRequest);
$this->mockActionRequest->setControllerObjectName(\TYPO3\Flow\Tests\Functional\Security\Fixtures\Controller\AuthenticationController::class);
$this->securityContext->setRequest($this->mockActionRequest);
$this->securityInitialized = true;
}
示例13: initializeControllerContext
/**
* The Resource Information most likely needs an UriBuilder, so having a
* ControllerContext in place might come in handy.
*
* @return void
*/
protected function initializeControllerContext()
{
$request = new ActionRequest(Request::createFromEnvironment());
$request->setDispatched(true);
$response = new Response();
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($request);
$arguments = new Arguments(array());
$this->controllerContext = new ControllerContext($request, $response, $arguments, $uriBuilder);
}
示例14: 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 = Request::createFromEnvironment();
$this->response = new Response();
$this->boot();
$this->resolveDependencies();
$this->addPoweredByHeader($this->response);
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(Bootstrap::RUNLEVEL_RUNTIME);
$this->exit->__invoke();
}
示例15: initializeObject
/**
* Initiates the StandaloneView by creating the required ControllerContext
*
* @return void
*/
public function initializeObject()
{
if ($this->request === NULL) {
$httpRequest = Request::createFromEnvironment();
$this->request = $httpRequest->createActionRequest();
}
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($this->request);
$this->setControllerContext(new ControllerContext($this->request, new Response(), new Arguments(array()), $uriBuilder, $this->flashMessageContainer));
}