Skip to content

Commit

Permalink
Fix state loading
Browse files Browse the repository at this point in the history
Nette only recognize persistent params as typed when they have default value.

nette/application#230

Since users are allowed to set various static properties after the construction of VP,
we cannot set the default values and need to convert the params manually.
  • Loading branch information
jtojnar committed Sep 11, 2019
1 parent e8d7a52 commit c9fcd15
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/VisualPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public function getPaginator(): Nette\Utils\Paginator {
if ($this->paginator === NULL) {
$this->paginator = new Utils\Paginator;
}
$this->paginator->page = ($this->page === NULL ? 1 : $this->page);
$this->paginator->itemsPerPage = ($this->itemsPerPage === NULL ? array_keys(self::$itemsPerPageList)[0] : $this->itemsPerPage);
$this->paginator->page = ($this->page === NULL ? 1 : (int) $this->page);
$this->paginator->itemsPerPage = ($this->itemsPerPage === NULL ? array_keys(self::$itemsPerPageList)[0] : (int) $this->itemsPerPage);
return $this->paginator;
}

Expand Down Expand Up @@ -232,8 +232,8 @@ public function loadState(array $params): void {
}
}

$this->getPaginator()->page = ($this->page === NULL ? 1 : $this->page);
$this->getPaginator()->itemsPerPage = ($this->itemsPerPage === NULL ? array_keys(self::$itemsPerPageList)[0] : $this->itemsPerPage);
$this->getPaginator()->page = ($this->page === NULL ? 1 : (int) $this->page);
$this->getPaginator()->itemsPerPage = ($this->itemsPerPage === NULL ? array_keys(self::$itemsPerPageList)[0] : (int) $this->itemsPerPage);
$this->page = $this->getPaginator()->page;
$this->itemsPerPage = $this->getPaginator()->itemsPerPage;

Expand Down

0 comments on commit c9fcd15

Please sign in to comment.