<?php
namespace App\Repository;
use App\Entity\Role\Role;
use App\Repository\Interfaces\RoleRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\ORM\QueryBuilder;
/**
* @method Role|null find($id, $lockMode = null, $lockVersion = null)
* @method Role|null findOneBy(array $criteria, array $orderBy = null)
* @method Role[] findAll()
* @method Role[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class RoleRepository extends ServiceEntityRepository implements RoleRepositoryInterface
{
/**
* RoleRepository constructor.
*
* @param ManagerRegistry $managerRegistry
*/
public function __construct(ManagerRegistry $managerRegistry)
{
parent::__construct(
$managerRegistry,
Role::class
);
}
/**
* {@inheritdoc}
*/
public function createGetAllEntitiesQueryBuilder(): QueryBuilder
{
$queryBuilder = $this->createQueryBuilder('roles')->orderBy(
'roles.id',
'DESC'
);
return $queryBuilder;
}
/**
* {@inheritdoc}
*/
public function save(Role $entity): void
{
$this->_em->persist($entity);
$this->_em->flush();
}
}