mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
crudification + corrections on thirdparty
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
namespace Chill\ThirdPartyBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\AbstractCRUDController;
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyACLAwareRepositoryInterface;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
@@ -16,12 +21,7 @@ use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
|
||||
/**
|
||||
* Routes for operations on ThirdParties.
|
||||
*
|
||||
* @Route("/{_locale}/thirdparty/thirdparty")
|
||||
*/
|
||||
class ThirdPartyController extends Controller
|
||||
final class ThirdPartyController extends CRUDController
|
||||
{
|
||||
/**
|
||||
*
|
||||
@@ -41,37 +41,33 @@ class ThirdPartyController extends Controller
|
||||
*/
|
||||
protected $paginatorFactory;
|
||||
|
||||
protected ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository;
|
||||
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
TranslatorInterface $translator,
|
||||
PaginatorFactory $paginatorFactory
|
||||
PaginatorFactory $paginatorFactory,
|
||||
ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository
|
||||
) {
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->translator = $translator;
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
$this->thirdPartyACLAwareRepository = $thirdPartyACLAwareRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/index", name="chill_3party_3party_index")
|
||||
*/
|
||||
public function indexAction()
|
||||
protected function countEntities(string $action, Request $request): int
|
||||
{
|
||||
$this->denyAccessUnlessGranted(ThirdPartyVoter::SHOW);
|
||||
$repository = $this->getDoctrine()->getManager()
|
||||
->getRepository(ThirdParty::class);
|
||||
|
||||
$nbThirdParties = $repository->count([]); //$repository->countByMemberOfCenters($centers);
|
||||
$pagination = $this->paginatorFactory->create($nbThirdParties);
|
||||
|
||||
$thirdParties = $repository->findAll();
|
||||
|
||||
return $this->render('ChillThirdPartyBundle:ThirdParty:index.html.twig', array(
|
||||
'third_parties' => $thirdParties,
|
||||
'pagination' => $pagination
|
||||
));
|
||||
return $this->thirdPartyACLAwareRepository->countThirdParties(ThirdPartyVoter::SHOW);
|
||||
}
|
||||
|
||||
protected function getQueryResult(string $action, Request $request, int $totalItems, PaginatorInterface $paginator)
|
||||
{
|
||||
return $this->thirdPartyACLAwareRepository
|
||||
->listThirdParties(ThirdPartyVoter::class, ['name' => 'ASC'], $paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/new", name="chill_3party_3party_new")
|
||||
*/
|
||||
|
Reference in New Issue
Block a user