diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index 3854525b8..092445c9b 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -19,14 +19,13 @@ namespace Chill\MainBundle\Entity; -use App\Repository\Chill\MainBundle\Entity\NotificationRepository; use Chill\MainBundle\Entity\User; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** - * @ORM\Entity(repositoryClass=NotificationRepository::class) + * @ORM\Entity * @ORM\Table( * name="chill_main_notification", * uniqueConstraints={ diff --git a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php index 04d6def1b..844459f8b 100644 --- a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php @@ -20,20 +20,47 @@ namespace Chill\MainBundle\Repository; use Chill\MainBundle\Entity\Notification; -use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; -use Doctrine\Persistence\ManagerRegistry; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\EntityRepository; +use Doctrine\Persistence\ObjectRepository; -/** - * @method Notification|null find($id, $lockMode = null, $lockVersion = null) - * @method Notification|null findOneBy(array $criteria, array $orderBy = null) - * @method Notification[] findAll() - * @method Notification[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class NotificationRepository extends ServiceEntityRepository +final class NotificationRepository implements ObjectRepository { - public function __construct(ManagerRegistry $registry) + private EntityRepository $repository; + + public function __construct(EntityManagerInterface $entityManager) { - parent::__construct($registry, Notification::class); + $this->repository = $entityManager->getRepository(Notification::class); + } + + public function find($id, $lockMode = null, $lockVersion = null): ?Notification + { + return $this->repository->find($id, $lockMode, $lockVersion); + } + + public function findOneBy(array $criteria, array $orderBy = null): ?Notification + { + return $this->repository->findOneBy($criteria, $orderBy); + } + + /** + * @return Notification[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @return Notification[] + */ + public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function getClassName() { + return Notification::class; } } diff --git a/src/Bundle/ChillMainBundle/config/services/repositories.yaml b/src/Bundle/ChillMainBundle/config/services/repositories.yaml index 18fd70df8..551a2f705 100644 --- a/src/Bundle/ChillMainBundle/config/services/repositories.yaml +++ b/src/Bundle/ChillMainBundle/config/services/repositories.yaml @@ -32,11 +32,3 @@ services: - "Chill\\MainBundle\\Entity\\Center" Chill\MainBundle\Repository\CenterRepository: '@chill.main.center_repository' - - chill.main.notification_repository: - class: Doctrine\ORM\EntityRepository - factory: ["@doctrine.orm.entity_manager", getRepository] - arguments: - - "Chill\\MainBundle\\Entity\\Notification" - - Chill\MainBundle\Repository\NotificationRepository: '@chill.main.notification_repository'