本文整理汇总了PHP中TYPO3\Flow\Mvc\ActionRequest::getMainRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP ActionRequest::getMainRequest方法的具体用法?PHP ActionRequest::getMainRequest怎么用?PHP ActionRequest::getMainRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Mvc\ActionRequest
的用法示例。
在下文中一共展示了ActionRequest::getMainRequest方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMainRequestReturnsTheTopLevelActionRequestWhoseParentIsTheHttpRequest
/**
* @test
*/
public function getMainRequestReturnsTheTopLevelActionRequestWhoseParentIsTheHttpRequest()
{
$anotherActionRequest = new ActionRequest($this->actionRequest);
$yetAnotherActionRequest = new ActionRequest($anotherActionRequest);
$this->assertSame($this->actionRequest, $this->actionRequest->getMainRequest());
$this->assertSame($this->actionRequest, $yetAnotherActionRequest->getMainRequest());
$this->assertSame($this->actionRequest, $anotherActionRequest->getMainRequest());
}
示例2: getMainRequestReturnsTheTopLevelActionRequestWhoseParentIsTheHttpRequest
/**
* @test
*/
public function getMainRequestReturnsTheTopLevelActionRequestWhoseParentIsTheHttpRequest()
{
$httpRequest = HttpRequest::create(new Uri('http://robertlemke.com/blog'));
$actionRequest = new ActionRequest($httpRequest);
$anotherActionRequest = new ActionRequest($actionRequest);
$yetAnotherActionRequest = new ActionRequest($anotherActionRequest);
$this->assertSame($actionRequest, $actionRequest->getMainRequest());
$this->assertSame($actionRequest, $yetAnotherActionRequest->getMainRequest());
$this->assertSame($actionRequest, $anotherActionRequest->getMainRequest());
}
示例3: getThumbnailUriAndSizeForAsset
/**
* Calculates the dimensions of the thumbnail to be generated and returns the thumbnail URI.
* In case of Images this is a thumbnail of the image, in case of other assets an icon representation.
*
* @param AssetInterface $asset
* @param ThumbnailConfiguration $configuration
* @param ActionRequest $request Request argument must be provided for asynchronous thumbnails
* @return array|null Array with keys "width", "height" and "src" if the thumbnail generation work or null
* @throws AssetServiceException
*/
public function getThumbnailUriAndSizeForAsset(AssetInterface $asset, ThumbnailConfiguration $configuration, ActionRequest $request = null)
{
$thumbnailImage = $this->thumbnailService->getThumbnail($asset, $configuration);
if (!$thumbnailImage instanceof ImageInterface) {
return null;
}
$resource = $thumbnailImage->getResource();
if ($thumbnailImage instanceof Thumbnail) {
$staticResource = $thumbnailImage->getStaticResource();
if ($configuration->isAsync() === true && $resource === null && $staticResource === null) {
if ($request === null) {
throw new AssetServiceException('Request argument must be provided for async thumbnails.', 1447660835);
}
$this->uriBuilder->setRequest($request->getMainRequest());
$uri = $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->uriFor('thumbnail', array('thumbnail' => $thumbnailImage), 'Thumbnail', 'TYPO3.Media');
} else {
$uri = $this->thumbnailService->getUriForThumbnail($thumbnailImage);
}
} else {
$uri = $this->resourceManager->getPublicPersistentResourceUri($resource);
}
return array('width' => $thumbnailImage->getWidth(), 'height' => $thumbnailImage->getHeight(), 'src' => $uri);
}
示例4: getMainRequest
/**
* Returns the top level ActionRequest: the one just below the HTTP request
*
* @return ActionRequest
* @api
*/
public function getMainRequest()
{
return $this->parentRequest instanceof HttpRequest ? $this : $this->parentRequest->getMainRequest();
}
示例5: getMainRequest
/**
* Get a new RequestMatcher for the Request's MainRequest
*
* @return \TYPO3\Flow\Mvc\RequestMatcher
* @api
*/
public function getMainRequest()
{
$this->addWeight(100000);
return new RequestMatcher($this->request->getMainRequest(), $this);
}
示例6: generateUriForNode
/**
* This method generates the Uri through the joinPoint with
* temporary overriding the used node
*
* @param ActionRequest $request
* @param JoinPointInterface $joinPoint The current join point
* @param NodeInterface $node
* @return string $uri
*/
public function generateUriForNode(ActionRequest $request, JoinPointInterface $joinPoint, NodeInterface $node)
{
// store original node path to restore it after generating the uri
$originalNodePath = $request->getMainRequest()->getArgument('node');
// generate the uri for the given node
$request->getMainRequest()->setArgument('node', $node->getContextPath());
$result = $joinPoint->getAdviceChain()->proceed($joinPoint);
// restore the original node path
$request->getMainRequest()->setArgument('node', $originalNodePath);
return $result;
}
示例7: mergeArgumentsWithRequestArguments
/**
* Merges specified arguments with arguments from request.
*
* If $this->request is no sub request, request arguments will only be merged if $this->addQueryString is set.
* Otherwise all request arguments except for the ones prefixed with the current request argument namespace will
* be merged. Additionally special arguments (PackageKey, SubpackageKey, ControllerName & Action) are merged.
*
* The argument provided through the $arguments parameter always overrule the request
* arguments.
*
* The request hierarchy is structured as follows:
* root (HTTP) > main (Action) > sub (Action) > sub sub (Action)
*
* @param array $arguments
* @return array
*/
protected function mergeArgumentsWithRequestArguments(array $arguments)
{
if ($this->request !== $this->request->getMainRequest()) {
$subRequest = $this->request;
while ($subRequest instanceof \TYPO3\Flow\Mvc\ActionRequest) {
$requestArguments = (array) $subRequest->getArguments();
// Reset arguments for the request that is bound to this UriBuilder instance
if ($subRequest === $this->request) {
if ($this->addQueryString === false) {
$requestArguments = array();
} else {
foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
unset($requestArguments[$argumentToBeExcluded]);
}
}
} else {
// Remove all arguments of the current sub request if it's namespaced
if ($this->request->getArgumentNamespace() !== '') {
$requestNamespace = $this->getRequestNamespacePath($this->request);
if ($this->addQueryString === false) {
$requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace);
} else {
foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
$requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace . '.' . $argumentToBeExcluded);
}
}
}
}
// Merge special arguments (package, subpackage, controller & action) from main request
$requestPackageKey = $subRequest->getControllerPackageKey();
if (!empty($requestPackageKey)) {
$requestArguments['@package'] = $requestPackageKey;
}
$requestSubpackageKey = $subRequest->getControllerSubpackageKey();
if (!empty($requestSubpackageKey)) {
$requestArguments['@subpackage'] = $requestSubpackageKey;
}
$requestControllerName = $subRequest->getControllerName();
if (!empty($requestControllerName)) {
$requestArguments['@controller'] = $requestControllerName;
}
$requestActionName = $subRequest->getControllerActionName();
if (!empty($requestActionName)) {
$requestArguments['@action'] = $requestActionName;
}
if (count($requestArguments) > 0) {
$requestArguments = $this->addNamespaceToArguments($requestArguments, $subRequest);
$arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments);
}
$subRequest = $subRequest->getParentRequest();
}
} elseif ($this->addQueryString === true) {
$requestArguments = $this->request->getArguments();
foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
unset($requestArguments[$argumentToBeExcluded]);
}
if ($requestArguments !== array()) {
$arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments);
}
}
return $arguments;
}
示例8: passArgumentsToPluginRequest
/**
* Pass the arguments which were addressed to the plugin to its own request
*
* @param ActionRequest $pluginRequest The plugin request
* @return void
*/
protected function passArgumentsToPluginRequest(ActionRequest $pluginRequest)
{
$arguments = $pluginRequest->getMainRequest()->getPluginArguments();
$pluginNamespace = $this->getPluginNamespace();
if (isset($arguments[$pluginNamespace])) {
$pluginRequest->setArguments($arguments[$pluginNamespace]);
}
}
示例9: __construct
/**
* @param \TYPO3\Form\Core\Model\FormDefinition $formDefinition
* @param \TYPO3\Flow\Mvc\ActionRequest $request
* @param \TYPO3\Flow\Http\Response $response
* @throws \TYPO3\Form\Exception\IdentifierNotValidException
* @internal
*/
public function __construct(\TYPO3\Form\Core\Model\FormDefinition $formDefinition, \TYPO3\Flow\Mvc\ActionRequest $request, \TYPO3\Flow\Http\Response $response)
{
$this->formDefinition = $formDefinition;
$rootRequest = $request->getMainRequest() ?: $request;
$pluginArguments = $rootRequest->getPluginArguments();
$this->request = new ActionRequest($request);
$formIdentifier = $this->formDefinition->getIdentifier();
$this->request->setArgumentNamespace('--' . $formIdentifier);
if (isset($pluginArguments[$formIdentifier])) {
$this->request->setArguments($pluginArguments[$formIdentifier]);
}
$this->response = $response;
}