mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
add possibility to generate filter/order elements, with only search box
for now
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Chill\ThirdPartyBundle\Controller;
|
||||
use Chill\MainBundle\CRUD\Controller\AbstractCRUDController;
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyACLAwareRepositoryInterface;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
@@ -56,15 +57,20 @@ final class ThirdPartyController extends CRUDController
|
||||
$this->thirdPartyACLAwareRepository = $thirdPartyACLAwareRepository;
|
||||
}
|
||||
|
||||
protected function countEntities(string $action, Request $request): int
|
||||
protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
|
||||
{
|
||||
return $this->thirdPartyACLAwareRepository->countThirdParties(ThirdPartyVoter::SHOW);
|
||||
if (NULL === $filterOrder){
|
||||
throw new \LogicException('filterOrder should not be null');
|
||||
}
|
||||
|
||||
return $this->thirdPartyACLAwareRepository->countThirdParties(ThirdPartyVoter::SHOW,
|
||||
$filterOrder->getQueryString());
|
||||
}
|
||||
|
||||
protected function getQueryResult(string $action, Request $request, int $totalItems, PaginatorInterface $paginator)
|
||||
protected function getQueryResult(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, ?FilterOrderHelper $filterOrder = null)
|
||||
{
|
||||
return $this->thirdPartyACLAwareRepository
|
||||
->listThirdParties(ThirdPartyVoter::class, ['name' => 'ASC'], $paginator->getItemsPerPage(),
|
||||
->listThirdParties(ThirdPartyVoter::SHOW, $filterOrder->getQueryString(), ['name' => 'ASC'], $paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber());
|
||||
}
|
||||
|
||||
@@ -78,4 +84,12 @@ final class ThirdPartyController extends CRUDController
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper
|
||||
{
|
||||
return $this->getFilterOrderHelperFactory()
|
||||
->create(self::class)
|
||||
->addSearchBox(['name', 'company_name', 'acronym'])
|
||||
->build();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user