本文整理汇总了PHP中TYPO3\Flow\Mvc\ActionRequest::setFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP ActionRequest::setFormat方法的具体用法?PHP ActionRequest::setFormat怎么用?PHP ActionRequest::setFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Mvc\ActionRequest
的用法示例。
在下文中一共展示了ActionRequest::setFormat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: theRepresentationFormatCanBeSetAndRetrieved
/**
* @test
*/
public function theRepresentationFormatCanBeSetAndRetrieved()
{
$this->actionRequest->setFormat('html');
$this->assertEquals('html', $this->actionRequest->getFormat());
$this->actionRequest->setFormat('doc');
$this->assertEquals('doc', $this->actionRequest->getFormat());
$this->actionRequest->setFormat('hTmL');
$this->assertEquals('html', $this->actionRequest->getFormat());
}
示例2: indexAction
/**
* @param array $module
* @return mixed
*/
public function indexAction(array $module)
{
$moduleRequest = new ActionRequest($this->request);
$moduleRequest->setArgumentNamespace('moduleArguments');
$moduleRequest->setControllerObjectName($module['controller']);
$moduleRequest->setControllerActionName($module['action']);
if (isset($module['format'])) {
$moduleRequest->setFormat($module['format']);
}
if ($this->request->hasArgument($moduleRequest->getArgumentNamespace()) === true && is_array($this->request->getArgument($moduleRequest->getArgumentNamespace()))) {
$moduleRequest->setArguments($this->request->getArgument($moduleRequest->getArgumentNamespace()));
}
foreach ($this->request->getPluginArguments() as $argumentNamespace => $argument) {
$moduleRequest->setArgument('--' . $argumentNamespace, $argument);
}
$modules = explode('/', $module['module']);
$moduleConfiguration = Arrays::getValueByPath($this->settings['modules'], implode('.submodules.', $modules));
$moduleConfiguration['path'] = $module['module'];
if (!$this->menuHelper->isModuleEnabled($moduleConfiguration['path'])) {
throw new DisabledModuleException(sprintf('The module "%s" is disabled. You can enable it with the "enabled" flag in Settings.yaml.', $module['module']), 1437148922);
}
$moduleBreadcrumb = array();
$path = array();
foreach ($modules as $moduleIdentifier) {
array_push($path, $moduleIdentifier);
$config = Arrays::getValueByPath($this->settings['modules'], implode('.submodules.', $path));
$moduleBreadcrumb[implode('/', $path)] = $config;
}
$moduleRequest->setArgument('__moduleConfiguration', $moduleConfiguration);
$moduleResponse = new Response($this->response);
$this->dispatcher->dispatch($moduleRequest, $moduleResponse);
if ($moduleResponse->hasHeader('Location')) {
$this->redirectToUri($moduleResponse->getHeader('Location'), 0, $moduleResponse->getStatusCode());
} elseif ($moduleRequest->getFormat() !== 'html') {
$mediaType = MediaTypes::getMediaTypeFromFilename('file.' . $moduleRequest->getFormat());
if ($mediaType !== 'application/octet-stream') {
$this->controllerContext->getResponse()->setHeader('Content-Type', $mediaType);
}
return $moduleResponse->getContent();
} else {
$user = $this->securityContext->getPartyByType('TYPO3\\Neos\\Domain\\Model\\User');
$sites = $this->menuHelper->buildSiteList($this->controllerContext);
$this->view->assignMultiple(array('moduleClass' => implode('-', $modules), 'moduleContents' => $moduleResponse->getContent(), 'title' => $moduleRequest->hasArgument('title') ? $moduleRequest->getArgument('title') : $moduleConfiguration['label'], 'rootModule' => array_shift($modules), 'submodule' => array_shift($modules), 'moduleConfiguration' => $moduleConfiguration, 'moduleBreadcrumb' => $moduleBreadcrumb, 'user' => $user, 'modules' => $this->menuHelper->buildModuleList($this->controllerContext), 'sites' => $sites));
}
}
示例3: initializeController
/**
* Initializes the controller
*
* This method should be called by the concrete processRequest() method.
*
* @param \TYPO3\Flow\Mvc\RequestInterface $request
* @param \TYPO3\Flow\Mvc\ResponseInterface $response
* @throws \TYPO3\Flow\Mvc\Exception\UnsupportedRequestTypeException
*/
protected function initializeController(\TYPO3\Flow\Mvc\RequestInterface $request, \TYPO3\Flow\Mvc\ResponseInterface $response)
{
if (!$request instanceof ActionRequest) {
throw new \TYPO3\Flow\Mvc\Exception\UnsupportedRequestTypeException(get_class($this) . ' only supports action requests – requests of type "' . get_class($request) . '" given.', 1187701131);
}
$this->request = $request;
$this->request->setDispatched(true);
$this->response = $response;
$this->uriBuilder = new UriBuilder();
$this->uriBuilder->setRequest($this->request);
$this->arguments = new Arguments(array());
$this->controllerContext = new ControllerContext($this->request, $this->response, $this->arguments, $this->uriBuilder);
$mediaType = $request->getHttpRequest()->getNegotiatedMediaType($this->supportedMediaTypes);
if ($mediaType === null) {
$this->throwStatus(406);
}
if ($request->getFormat() === null) {
$this->request->setFormat(MediaTypes::getFilenameExtensionFromMediaType($mediaType));
}
}
示例4: interceptorsWorkInPartialRenderedInStandaloneSection
/**
* Tests the wrong interceptor behavior described in ticket FLOW-430
* Basically the rendering should be consistent regardless of cache flushes,
* but due to the way the interceptor configuration was build the second second
* rendering was bound to fail, this should never happen.
*
* @test
*/
public function interceptorsWorkInPartialRenderedInStandaloneSection()
{
$httpRequest = Request::create(new Uri('http://localhost'));
$actionRequest = new ActionRequest($httpRequest);
$actionRequest->setFormat('html');
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
$standaloneView->assign('hack', '<h1>HACK</h1>');
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/NestedRenderingConfiguration/TemplateWithSection.txt');
$expected = 'Christian uses <h1>HACK</h1>';
$actual = trim($standaloneView->renderSection('test'));
$this->assertSame($expected, $actual, 'First rendering was not escaped.');
// To avoid any side effects we create a separate accessible mock to find the cache identifier for the partial
$dummyTemplateView = $this->getAccessibleMock(StandaloneView::class, null, array($actionRequest, $this->standaloneViewNonce));
$partialCacheIdentifier = $dummyTemplateView->_call('createIdentifierForFile', __DIR__ . '/Fixtures/NestedRenderingConfiguration/Partials/Test.html', 'partial_Test');
$templateCache = $this->objectManager->get(CacheManager::class)->getCache('Fluid_TemplateCache');
$templateCache->remove($partialCacheIdentifier);
$expected = 'Christian uses <h1>HACK</h1>';
$actual = trim($standaloneView->renderSection('test'));
$this->assertSame($expected, $actual, 'Second rendering was not escaped.');
}
示例5: xmlNamespacesCanBeIgnored
/**
* @test
*/
public function xmlNamespacesCanBeIgnored()
{
$httpRequest = Request::create(new Uri('http://localhost'));
$actionRequest = new ActionRequest($httpRequest);
$actionRequest->setFormat('txt');
$standaloneView = new Fixtures\View\StandaloneView($actionRequest, $this->standaloneViewNonce);
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithCustomNamespaces.txt');
$standaloneView->setLayoutRootPath(__DIR__ . '/Fixtures/SpecialLayouts');
$expected = '<foo:bar /><bar:foo></bar:foo><foo.bar:baz />foobar';
$actual = $standaloneView->render();
$this->assertSame($expected, $actual);
}
示例6: explicitLayoutPathIsUsed
/**
* @test
*/
public function explicitLayoutPathIsUsed()
{
$httpRequest = Request::create(new Uri('http://localhost'));
$actionRequest = new ActionRequest($httpRequest);
$actionRequest->setFormat('txt');
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithLayout.txt');
$standaloneView->setLayoutRootPath(__DIR__ . '/Fixtures/SpecialLayouts');
$expected = 'Hey -- overridden -- HEY HO';
$actual = $standaloneView->render();
$this->assertSame($expected, $actual);
}
示例7: theRepresentationFormatCanBeSetAndRetrieved
/**
* @test
*/
public function theRepresentationFormatCanBeSetAndRetrieved()
{
$httpRequest = HttpRequest::create(new Uri('http://foo.com'));
$actionRequest = new ActionRequest($httpRequest);
$actionRequest->setFormat('html');
$this->assertEquals('html', $actionRequest->getFormat());
$actionRequest->setFormat('doc');
$this->assertEquals('doc', $actionRequest->getFormat());
$actionRequest->setFormat('hTmL');
$this->assertEquals('html', $actionRequest->getFormat());
}
示例8: redirectUsesRequestFormatAsDefaultAndUnsetsSubPackageKeyIfNeccessary
/**
* @test
*/
public function redirectUsesRequestFormatAsDefaultAndUnsetsSubPackageKeyIfNeccessary()
{
$arguments = array('foo' => 'bar');
$request = new ActionRequest(HttpRequest::create(new Uri('http://localhost/foo.json')));
$request->setFormat('json');
$response = new HttpResponse();
$mockUriBuilder = $this->getMock('TYPO3\\Flow\\Mvc\\Routing\\UriBuilder');
$mockUriBuilder->expects($this->once())->method('reset')->will($this->returnValue($mockUriBuilder));
$mockUriBuilder->expects($this->once())->method('setFormat')->with('json')->will($this->returnValue($mockUriBuilder));
$mockUriBuilder->expects($this->once())->method('setCreateAbsoluteUri')->will($this->returnValue($mockUriBuilder));
$mockUriBuilder->expects($this->once())->method('uriFor')->with('show', $arguments, 'Stuff', 'Super', NULL)->will($this->returnValue('the uri'));
$controller = $this->getAccessibleMock('TYPO3\\Flow\\Mvc\\Controller\\AbstractController', array('processRequest', 'redirectToUri'));
$this->inject($controller, 'flashMessageContainer', new FlashMessageContainer());
$controller->_call('initializeController', $request, $response);
$this->inject($controller, 'uriBuilder', $mockUriBuilder);
$controller->expects($this->once())->method('redirectToUri')->with('the uri');
$controller->_call('redirect', 'show', 'Stuff', 'Super', $arguments);
}