Skip to content
Snippets Groups Projects
Commit b4822aa6 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[BUGFIX] Do not extend UriViewHelper because it's messy and breaks in 9

parent 038dc3ca
No related branches found
No related tags found
1 merge request!13Feature upgrade to9 lts
......@@ -28,11 +28,15 @@ namespace SGalinski\SgMail\ViewHelpers\Widget;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
/**
* Class UriViewHelper
*/
class UriViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Widget\UriViewHelper {
class UriViewHelper extends AbstractViewHelper {
use CompileWithRenderStatic;
/**
* @var boolean
......@@ -44,6 +48,61 @@ class UriViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Widget\UriViewHelper {
*/
protected $escapeChildren = FALSE;
/**
* Initialize arguments
*/
public function initializeArguments() {
$this->registerArgument(
'useCacheHash', 'bool', 'True whether the cache hash should be appended to the URL', FALSE, FALSE
);
$this->registerArgument('addQueryStringMethod', 'string', 'Method to be used for query string');
$this->registerArgument('action', 'string', 'Target action');
$this->registerArgument('arguments', 'array', 'Arguments', FALSE, []);
$this->registerArgument('section', 'string', 'The anchor to be added to the URI', FALSE, '');
$this->registerArgument('format', 'string', 'The requested format, e.g. ".html', FALSE, '');
$this->registerArgument(
'ajax', 'bool', 'TRUE if the URI should be to an AJAX widget, FALSE otherwise.', FALSE, FALSE
);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(
array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext
) {
$ajax = $arguments['ajax'];
if ($ajax === TRUE) {
return static::getAjaxUri($renderingContext, $arguments);
}
return static::getWidgetUri($renderingContext, $arguments);
}
/**
* Get the URI for an AJAX Request.
*
* @param RenderingContextInterface $renderingContext
* @param array $arguments
* @return string the AJAX URI
*/
protected static function getAjaxUri(RenderingContextInterface $renderingContext, array $arguments) {
$controllerContext = $renderingContext->getControllerContext();
$action = $arguments['action'];
$arguments = $arguments['arguments'];
if ($action === NULL) {
$action = $controllerContext->getRequest()->getControllerActionName();
}
$arguments['id'] = $GLOBALS['TSFE']->id;
// @todo page type should be configurable
$arguments['type'] = 7076;
$arguments['fluid-widget-id'] = $controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
$arguments['action'] = $action;
return '?' . http_build_query($arguments, NULL, '&');
}
/**
* Get the URI for a non-AJAX Request.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment