Skip to content

Commit

Permalink
Add template for datagrid (#7037)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored Apr 14, 2021
1 parent 2288631 commit 9524621
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Datagrid/Datagrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* @final since sonata-project/admin-bundle 3.52
*
* @author Thomas Rabaix <[email protected]>
*
* @phpstan-template T of ProxyQueryInterface
* @phpstan-implements DatagridInterface<T>
*/
class Datagrid implements DatagridInterface
{
Expand All @@ -49,6 +52,7 @@ class Datagrid implements DatagridInterface

/**
* @var PagerInterface
* @phpstan-var PagerInterface<T>
*/
protected $pager;

Expand All @@ -59,6 +63,7 @@ class Datagrid implements DatagridInterface

/**
* @var ProxyQueryInterface
* @phpstan-var T
*/
protected $query;

Expand All @@ -77,6 +82,10 @@ class Datagrid implements DatagridInterface
*/
protected $results;

/**
* @phpstan-param T $query
* @phpstan-param PagerInterface<T> $pager
*/
public function __construct(
ProxyQueryInterface $query,
FieldDescriptionCollection $columns,
Expand Down
6 changes: 6 additions & 0 deletions src/Datagrid/DatagridInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@
*
* @method array getSortParameters(FieldDescriptionInterface $fieldDescription)
* @method array getPaginationParameters(int $page)
*
* @phpstan-template T of ProxyQueryInterface
*/
interface DatagridInterface
{
/**
* @return PagerInterface
*
* @phpstan-return PagerInterface<T>
*/
public function getPager();

/**
* @return ProxyQueryInterface
*
* @phpstan-return T
*/
public function getQuery();

Expand Down

0 comments on commit 9524621

Please sign in to comment.