for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Potievdev\SlimRbac\Models\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\QueryException;
/**
* UserRoleRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class UserRoleRepository extends EntityRepository
{
* Returns array of user role ids.
* @throws QueryException
public function getUserRoleIds(string $userId): array
$qb = $this->createQueryBuilder('userRole');
$qb->select('userRole.roleId')
->where($qb->expr()->eq('userRole.userId', $userId))
->indexBy('userRole', 'userRole.roleId');
$roleIds = $qb->getQuery()->getArrayResult();
return array_keys($roleIds);
}