Skip to content

Commit

Permalink
Removed custom isAjax override, did not work
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk committed May 21, 2024
1 parent ce470b1 commit 80308c3
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/Traits/RedirectAjaxHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace JuniWalk\Utils\Traits;

use Nette\Application\AbortException;
use Nette\Application\UI\Presenter;

trait RedirectAjaxHandler
{
Expand All @@ -19,31 +18,18 @@ trait RedirectAjaxHandler
*/
public function redirect(string $dest, mixed ...$args): void
{
$self = $this->getPresenter();
$payload = $self->getPayload();
$presenter = $this->getPresenter();

unset($payload->postGet);
unset($payload->url);

if (!$self->isAjax()) {
if (!$presenter->isAjax() || $this->forceRedirect) {
parent::redirect($dest, ...$args);
}

$payload = $presenter->getPayload();
$payload->url = $this->link($dest, ...$args);
$payload->postGet = true;
}


public function isAjax(): bool
{
if (!$this instanceof Presenter) {
return $this->getPresenter()->isAjax();
}

return parent::isAjax() && !$this->forceRedirect;
}


public function forceRedirect(): static
{
$this->forceRedirect = true;
Expand Down

0 comments on commit 80308c3

Please sign in to comment.