Skip to content

Commit 9c46efd

Browse files
committed
UI\Presenter::canonicalize() allows to redirect to specified destination
1 parent 66cd441 commit 9c46efd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Application/UI/Presenter.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,16 @@ public function getLastCreatedRequestFlag(string $flag): bool
671671
* Conditional redirect to canonicalized URI.
672672
* @throws Nette\Application\AbortException
673673
*/
674-
public function canonicalize(): void
674+
public function canonicalize(string $destination = NULL, array $args = []): void
675675
{
676676
if (!$this->isAjax() && ($this->request->isMethod('get') || $this->request->isMethod('head'))) {
677677
try {
678-
$url = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->getParameters(), 'redirectX');
678+
$url = $this->createRequest(
679+
$this,
680+
$destination ?: $this->action,
681+
$args + $this->getGlobalState() + $this->request->getParameters(),
682+
'redirectX'
683+
);
679684
} catch (InvalidLinkException $e) {
680685
}
681686
if (isset($url) && !$this->httpRequest->getUrl()->isEqual($url)) {

0 commit comments

Comments
 (0)