toolbar dropdown and visibility improvements (#933)
This commit is contained in:
@@ -9,12 +9,11 @@
|
||||
|
||||
namespace App\Repository\Paginator;
|
||||
|
||||
use App\Repository\Loader\TimesheetLoader;
|
||||
use App\Repository\Loader\LoaderInterface;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Pagerfanta\Adapter\AdapterInterface;
|
||||
|
||||
final class TimesheetPaginator implements AdapterInterface
|
||||
final class LoaderPaginator implements PaginatorInterface
|
||||
{
|
||||
/**
|
||||
* @var QueryBuilder
|
||||
@@ -25,15 +24,15 @@ final class TimesheetPaginator implements AdapterInterface
|
||||
*/
|
||||
private $results = 0;
|
||||
/**
|
||||
* @var TimesheetLoader
|
||||
* @var LoaderInterface
|
||||
*/
|
||||
private $loader;
|
||||
|
||||
public function __construct(QueryBuilder $query, int $results)
|
||||
public function __construct(LoaderInterface $loader, QueryBuilder $query, int $results)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
$this->query = $query;
|
||||
$this->results = $results;
|
||||
$this->loader = new TimesheetLoader($query->getEntityManager());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,15 +43,6 @@ final class TimesheetPaginator implements AdapterInterface
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
private function getResults(Query $query)
|
||||
{
|
||||
$results = $query->execute();
|
||||
|
||||
$this->loader->loadResults($results);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -66,7 +56,16 @@ final class TimesheetPaginator implements AdapterInterface
|
||||
return $this->getResults($query);
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
private function getResults(Query $query)
|
||||
{
|
||||
$results = $query->execute();
|
||||
|
||||
$this->loader->loadResults($results);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getAll(): iterable
|
||||
{
|
||||
return $this->getResults($this->query->getQuery());
|
||||
}
|
||||
22
src/Repository/Paginator/PaginatorInterface.php
Normal file
22
src/Repository/Paginator/PaginatorInterface.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Repository\Paginator;
|
||||
|
||||
use Pagerfanta\Adapter\AdapterInterface;
|
||||
|
||||
interface PaginatorInterface extends AdapterInterface
|
||||
{
|
||||
/**
|
||||
* Returns all available results without pagination.
|
||||
*
|
||||
* @return iterable
|
||||
*/
|
||||
public function getAll(): iterable;
|
||||
}
|
||||
Reference in New Issue
Block a user