Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions Classes/ViewHelpers/Pagination/UriViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
namespace Pluswerk\MailLogger\ViewHelpers\Pagination;

use Override;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\Routing\Route as SymfonyRoute;
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
use TYPO3\CMS\Backend\Routing\Route;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;

class UriViewHelper extends AbstractTagBasedViewHelper
Expand All @@ -27,16 +31,17 @@ public function initializeArguments(): void
}

/**
* Build an uri to current action with &tx_ext_plugin[currentPage]=2
* Build an uri to current action with &tx_maillogger_iocenter[currentPage]=2
*
* @return string The rendered uri
*/
#[Override]
public function render(): string
{
$pluginNamespace = 'tx_maillogger_iocenter';
$argumentPrefix = $pluginNamespace . '[' . $this->arguments['name'] . ']';
$argumentPrefix = 'tx_maillogger_iocenter[' . $this->arguments['name'] . ']';

$arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : [];

if ($this->hasArgument('action')) {
$arguments['action'] = $this->arguments['action'];
}
Expand All @@ -45,10 +50,15 @@ public function render(): string
$arguments['format'] = $this->arguments['format'];
}

return $this->uriBuilder->reset()
->setArguments([$argumentPrefix => $arguments])
->setAddQueryString(true)
->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash'])
->build();
$request = $this->renderingContext->hasAttribute(ServerRequestInterface::class)
? $this->renderingContext->getAttribute(ServerRequestInterface::class)
: $GLOBALS['TYPO3_REQUEST'];

$route = $request->getAttribute('route');
if (!$route instanceof Route && !$route instanceof SymfonyRoute) {
throw new RouteNotFoundException('No route object was given inside the request object', 1691423325);
}

return $this->uriBuilder->buildUriFromRoute($route->getOption('_identifier'), [$argumentPrefix => $arguments])->__toString();
}
}