mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
crudification + corrections on thirdparty
This commit is contained in:
@@ -2,22 +2,52 @@
|
||||
|
||||
namespace Chill\ThirdPartyBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @Author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
|
||||
*/
|
||||
class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepositoryInterface
|
||||
final class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepositoryInterface
|
||||
{
|
||||
private Security $security;
|
||||
private AuthorizationHelper $authorizationHelper;
|
||||
private ThirdPartyRepository $thirdPartyRepository;
|
||||
|
||||
public function findByThirdparty(
|
||||
ThirdParty $thirdparty,
|
||||
string $role,
|
||||
?array $orderBy = [],
|
||||
int $limit = null,
|
||||
int $offset = null
|
||||
public function __construct(Security $security, AuthorizationHelper $authorizationHelper, ThirdPartyRepository $thirdPartyRepository)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->thirdPartyRepository = $thirdPartyRepository;
|
||||
}
|
||||
|
||||
public function listThirdParties(
|
||||
string $role,
|
||||
?array $orderBy = [],
|
||||
?int $limit = null,
|
||||
?int $offset = null
|
||||
): array {
|
||||
$qb = $this->buildQuery($role);
|
||||
|
||||
// TODO: Implement findByThirdparty() method.
|
||||
foreach ($orderBy as $sort => $direction) {
|
||||
$qb->addOrderBy('tp.'.$sort, $direction);
|
||||
}
|
||||
|
||||
$qb->setFirstResult($offset)
|
||||
->setMaxResults($limit);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function countThirdParties(
|
||||
string $role
|
||||
): int {
|
||||
$qb = $this->buildQuery($role);
|
||||
$qb->select('count(tp)');
|
||||
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function buildQuery(): QueryBuilder {
|
||||
return $this->thirdPartyRepository->createQueryBuilder('tp');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user