Skip to content

Commit

Permalink
Merge pull request #5079 from mhsdesign/task/5076-remove-addQueryStri…
Browse files Browse the repository at this point in the history
…ng-and-argumentsToBeExcludedFromQueryString-in-neos

!!! TASK: Remove concepts `addQueryString` and `argumentsToBeExcludedFromQueryString` in Neos
  • Loading branch information
mhsdesign authored May 22, 2024
2 parents f0c9d09 + 139021f commit f2db0a7
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 156 deletions.
32 changes: 0 additions & 32 deletions Neos.Fusion/Classes/FusionObjects/ActionUriImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
* * format
* * section
* * additionalParams
* * addQueryString
* * argumentsToBeExcludedFromQueryString
* * absolute
* * request
*
Expand Down Expand Up @@ -126,26 +124,6 @@ public function getAdditionalParams(): ?array
return $this->fusionValue('additionalParams');
}

/**
* Arguments to be removed from the URI. Only active if addQueryString = true
*
* @return array|null
*/
public function getArgumentsToBeExcludedFromQueryString(): ?array
{
return $this->fusionValue('argumentsToBeExcludedFromQueryString');
}

/**
* If true, the current query parameters will be kept in the URI
*
* @return boolean
*/
public function isAddQueryString(): bool
{
return (boolean)$this->fusionValue('addQueryString');
}

/**
* If true, an absolute URI is rendered
*
Expand Down Expand Up @@ -174,11 +152,6 @@ public function evaluate()
$uriBuilder->setArguments($additionalParams);
}

$argumentsToBeExcludedFromQueryString = $this->getArgumentsToBeExcludedFromQueryString();
if ($argumentsToBeExcludedFromQueryString !== null) {
$uriBuilder->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString);
}

$absolute = $this->isAbsolute();
if ($absolute === true) {
$uriBuilder->setCreateAbsoluteUri(true);
Expand All @@ -189,11 +162,6 @@ public function evaluate()
$uriBuilder->setSection($section);
}

$addQueryString = $this->isAddQueryString();
if ($addQueryString === true) {
$uriBuilder->setAddQueryString(true);
}

try {
return $uriBuilder->uriFor(
$this->getAction(),
Expand Down
32 changes: 0 additions & 32 deletions Neos.Fusion/Classes/FusionObjects/UriBuilderImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* * format
* * section
* * additionalParams
* * addQueryString
* * argumentsToBeExcludedFromQueryString
* * absolute
*
* See respective getters for descriptions
Expand Down Expand Up @@ -118,26 +116,6 @@ public function getAdditionalParams()
return $this->fusionValue('additionalParams');
}

/**
* Arguments to be removed from the URI. Only active if addQueryString = true
*
* @return array
*/
public function getArgumentsToBeExcludedFromQueryString()
{
return $this->fusionValue('argumentsToBeExcludedFromQueryString');
}

/**
* If true, the current query parameters will be kept in the URI
*
* @return boolean
*/
public function isAddQueryString()
{
return (boolean)$this->fusionValue('addQueryString');
}

/**
* If true, an absolute URI is rendered
*
Expand Down Expand Up @@ -177,11 +155,6 @@ public function evaluate()
$uriBuilder->setArguments($additionalParams);
}

$argumentsToBeExcludedFromQueryString = $this->getArgumentsToBeExcludedFromQueryString();
if ($argumentsToBeExcludedFromQueryString !== null) {
$uriBuilder->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString);
}

$absolute = $this->isAbsolute();
if ($absolute === true) {
$uriBuilder->setCreateAbsoluteUri(true);
Expand All @@ -192,11 +165,6 @@ public function evaluate()
$uriBuilder->setSection($section);
}

$addQueryString = $this->isAddQueryString();
if ($addQueryString === true) {
$uriBuilder->setAddQueryString(true);
}

try {
return $uriBuilder->uriFor(
$this->getAction(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ prototype(Neos.Fusion:UriBuilder) {
additionalParams = Neos.Fusion:DataStructure {
@sortProperties = false
}
argumentsToBeExcludedFromQueryString = Neos.Fusion:DataStructure
arguments = Neos.Fusion:DataStructure {
@sortProperties = false
}
addQueryString = false
absolute = false

@exceptionHandler = 'Neos\\Fusion\\Core\\ExceptionHandlers\\AbsorbingHandler'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ prototype(Neos.Fusion:ActionUri) {
section = null
additionalParams = Neos.Fusion:DataStructure
arguments = Neos.Fusion:DataStructure
argumentsToBeExcludedFromQueryString = Neos.Fusion:DataStructure
addQueryString = false
absolute = false

@exceptionHandler = 'Neos\\Fusion\\Core\\ExceptionHandlers\\AbsorbingHandler'
Expand Down
24 changes: 1 addition & 23 deletions Neos.Neos/Classes/Fusion/NodeUriImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,6 @@ public function getAdditionalParams(): array
return array_merge($this->fusionValue('additionalParams'), $this->fusionValue('arguments'));
}

/**
* Arguments to be removed from the URI. Only active if addQueryString = true
*
* @return array<int,string>
*/
public function getArgumentsToBeExcludedFromQueryString(): array
{
return $this->fusionValue('argumentsToBeExcludedFromQueryString');
}

/**
* If true, the current query parameters will be kept in the URI
*
* @return boolean
*/
public function getAddQueryString()
{
return (bool)$this->fusionValue('addQueryString');
}

/**
* If true, an absolute URI is rendered
*
Expand Down Expand Up @@ -177,9 +157,7 @@ public function evaluate()
->setFormat($this->getFormat())
->setCreateAbsoluteUri($this->isAbsolute())
->setArguments($this->getAdditionalParams())
->setSection($this->getSection())
->setAddQueryString($this->getAddQueryString())
->setArgumentsToBeExcludedFromQueryString($this->getArgumentsToBeExcludedFromQueryString());
->setSection($this->getSection());

try {
return (string)NodeUriBuilder::fromUriBuilder($uriBuilder)->uriFor($nodeAddress);
Expand Down
31 changes: 17 additions & 14 deletions Neos.Neos/Classes/Service/LinkingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
use Neos\Neos\Domain\Repository\SiteRepository;
use Neos\Neos\Exception as NeosException;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\NodeShortcutResolver;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
use Neos\Utility\Arrays;
use Psr\Http\Message\UriInterface;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -88,12 +88,6 @@ class LinkingService
*/
protected $resourceManager;

/**
* @Flow\Inject
* @var NodeShortcutResolver
*/
protected $nodeShortcutResolver;

/**
* @Flow\Inject
* @var PropertyMapper
Expand Down Expand Up @@ -260,9 +254,9 @@ public function convertUriToObject($uri, Node $contextNode = null)
* @param array<string,mixed> $arguments Additional arguments to be passed to the UriBuilder
* (e.g. pagination parameters)
* @param string $section
* @param boolean $addQueryString If set, the current query parameters will be kept in the URI
* @param boolean $addQueryString If set, the current query parameters will be kept in the URI @deprecated see https://github.com/neos/neos-development-collection/issues/5076
* @param array<int,string> $argumentsToBeExcludedFromQueryString arguments to be removed from the URI.
* Only active if $addQueryString = true
* Only active if $addQueryString = true @deprecated see https://github.com/neos/neos-development-collection/issues/5076
* @param boolean $resolveShortcuts @deprecated With Neos 7.0 this argument is no longer evaluated
* and log a message if set to FALSE
* @return string The rendered URI
Expand Down Expand Up @@ -355,18 +349,27 @@ public function createNodeUri(
$workspace = $contentRepository->getWorkspaceFinder()->findOneByName(
$node->workspaceName
);
$request = $controllerContext->getRequest()->getMainRequest();
$mainRequest = $controllerContext->getRequest()->getMainRequest();
$uriBuilder = clone $controllerContext->getUriBuilder();
$uriBuilder->setRequest($request);
$uriBuilder->setRequest($mainRequest);
$action = $workspace && $workspace->isPublicWorkspace() && $node->tags->contain(SubtreeTag::disabled()) ? 'show' : 'preview';

if ($addQueryString === true) {
// legacy feature see https://github.com/neos/neos-development-collection/issues/5076
$requestArguments = $mainRequest->getArguments();
foreach ($argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
unset($requestArguments[$argumentToBeExcluded]);
}
if ($requestArguments !== []) {
$arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments);
}
}

return $uriBuilder
->reset()
->setSection($section)
->setArguments($arguments)
->setAddQueryString($addQueryString)
->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
->setFormat($format ?: $request->getFormat())
->setFormat($format ?: $mainRequest->getFormat())
->setCreateAbsoluteUri($absolute)
->uriFor($action, ['node' => $node], 'Frontend\Node', 'Neos.Neos');
}
Expand Down
4 changes: 2 additions & 2 deletions Neos.Neos/Classes/ViewHelpers/Link/ModuleViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ public function initializeArguments()
$this->registerArgument(
'addQueryString',
'boolean',
'If set, the current query parameters will be kept in the URI',
'Deprecated with Neos 9. If set, the current query parameters will be kept in the URI',
false,
false
);
$this->registerArgument(
'argumentsToBeExcludedFromQueryString',
'array',
'arguments to be removed from the URI. Only active if $addQueryString = true',
'Deprecated with Neos 9. arguments to be removed from the URI. Only active if $addQueryString = true',
false,
[]
);
Expand Down
18 changes: 1 addition & 17 deletions Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,6 @@ public function initializeArguments()
false,
''
);
$this->registerArgument(
'addQueryString',
'boolean',
'If set, the current query parameters will be kept in the URI',
false,
false
);
$this->registerArgument(
'argumentsToBeExcludedFromQueryString',
'array',
'arguments to be removed from the URI. Only active if $addQueryString = true',
false,
[]
);
$this->registerArgument(
'baseNodeName',
'string',
Expand Down Expand Up @@ -324,9 +310,7 @@ public function render(): string
$uriBuilder->setFormat($this->arguments['format'])
->setCreateAbsoluteUri($this->arguments['absolute'])
->setArguments($this->arguments['arguments'])
->setSection($this->arguments['section'])
->setAddQueryString($this->arguments['addQueryString'])
->setArgumentsToBeExcludedFromQueryString($this->arguments['argumentsToBeExcludedFromQueryString']);
->setSection($this->arguments['section']);

$uri = '';
try {
Expand Down
4 changes: 2 additions & 2 deletions Neos.Neos/Classes/ViewHelpers/Uri/ModuleViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ public function initializeArguments()
$this->registerArgument(
'addQueryString',
'string',
'If set, the current query parameters will be kept in the URI',
'Deprecated with Neos 9. If set, the current query parameters will be kept in the URI',
false,
false
);
$this->registerArgument(
'argumentsToBeExcludedFromQueryString',
'string',
'arguments to be removed from the URI. Only active if $addQueryString = true',
'Deprecated with Neos 9. arguments to be removed from the URI. Only active if $addQueryString = true',
false,
[]
);
Expand Down
18 changes: 1 addition & 17 deletions Neos.Neos/Classes/ViewHelpers/Uri/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,6 @@ public function initializeArguments()
false,
''
);
$this->registerArgument(
'addQueryString',
'boolean',
'If set, the current query parameters will be kept in the URI',
false,
false
);
$this->registerArgument(
'argumentsToBeExcludedFromQueryString',
'array',
'arguments to be removed from the URI. Only active if $addQueryString = true',
false,
[]
);
$this->registerArgument(
'baseNodeName',
'string',
Expand Down Expand Up @@ -227,9 +213,7 @@ public function render(): string
$uriBuilder->setFormat($this->arguments['format'])
->setCreateAbsoluteUri($this->arguments['absolute'])
->setArguments($this->arguments['arguments'])
->setSection($this->arguments['section'])
->setAddQueryString($this->arguments['addQueryString'])
->setArgumentsToBeExcludedFromQueryString($this->arguments['argumentsToBeExcludedFromQueryString']);
->setSection($this->arguments['section']);

$uri = '';
if (!$nodeAddress) {
Expand Down
6 changes: 0 additions & 6 deletions Neos.Neos/Documentation/References/NeosFusionReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,6 @@ Built a URI to a controller action
:format: (string) An optional request format (e.g. ``'html'``)
:section: (string) An optional fragment (hash) for the URI
:additionalParams: (array) Additional URI query parameters by named key
:addQueryString: (boolean) Whether to keep the query parameters of the current URI
:argumentsToBeExcludedFromQueryString: (array) Query parameters to exclude for ``addQueryString``
:absolute: (boolean) Whether to create an absolute URI

Example::
Expand Down Expand Up @@ -1181,8 +1179,6 @@ Build a URI to a node. Accepts the same arguments as the node link/uri view help
:format: (string) An optional request format (e.g. ``'html'``)
:section: (string) An optional fragment (hash) for the URI
:additionalParams: (array) Additional URI query parameters.
:argumentsToBeExcludedFromQueryString: (array) Query parameters to exclude for ``addQueryString``
:addQueryString: (boolean) Whether to keep current query parameters, defaults to ``FALSE``
:absolute: (boolean) Whether to create an absolute URI, defaults to ``FALSE``
:baseNodeName: (string) Base node context variable name (for relative paths), defaults to ``'documentNode'``

Expand Down Expand Up @@ -1355,8 +1351,6 @@ Built a URI to a controller action
:format: (string) An optional request format (e.g. ``'html'``)
:section: (string) An optional fragment (hash) for the URI
:additionalParams: (array) Additional URI query parameters by named key
:addQueryString: (boolean) Whether to keep the query parameters of the current URI
:argumentsToBeExcludedFromQueryString: (array) Query parameters to exclude for ``addQueryString``
:absolute: (boolean) Whether to create an absolute URI

.. note:: The use of ``Neos.Fusion:UriBuilder`` is deprecated. Use :ref:`Neos_Fusion__ActionUri` instead.
Expand Down
6 changes: 0 additions & 6 deletions Neos.Neos/Resources/Private/Fusion/Prototypes/NodeLink.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ prototype(Neos.Neos:NodeLink) < prototype(Neos.Fusion:Tag) {
node = null
additionalParams = Neos.Fusion:DataStructure
arguments = Neos.Fusion:DataStructure
argumentsToBeExcludedFromQueryString = Neos.Fusion:DataStructure
addQueryString = false
absolute = false
baseNodeName = 'documentNode'

@context {
node = ${this.node}
additionalParams = ${this.additionalParams}
arguments = ${this.arguments}
argumentsToBeExcludedFromQueryString = ${this.argumentsToBeExcludedFromQueryString}
addQueryString = ${this.addQueryString}
absolute = ${this.absolute}
baseNodeName = ${this.baseNodeName}
}
Expand All @@ -26,8 +22,6 @@ prototype(Neos.Neos:NodeLink) < prototype(Neos.Fusion:Tag) {
node = ${node}
additionalParams = ${additionalParams}
arguments = ${arguments}
argumentsToBeExcludedFromQueryString = ${argumentsToBeExcludedFromQueryString}
addQueryString = ${addQueryString}
absolute = ${absolute}
baseNodeName = ${baseNodeName}
}
Expand Down
Loading

0 comments on commit f2db0a7

Please sign in to comment.