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;
/**
* PermissionRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class PermissionRepository extends EntityRepository
{
* Finds permission by name. If it founded returns permission id
public function getPermissionIdByName(string $permissionName): ?int
$qb = $this->createQueryBuilder('permission');
$result = $qb->select('permission.id')
->where($qb->expr()->eq('permission.name', $qb->expr()->literal($permissionName)))
->setMaxResults(1)
->getQuery()
->getArrayResult();
if (count($result) > 0) {
return $result[0]['id'];
}
return null;