<?php
namespace App\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* Abstract repository.
*/
abstract class AbstractRepository extends ServiceEntityRepository
{
/**
* AbstractRepository constructor.
*
* @param ManagerRegistry $registry
*/
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, $this->getEntityClass());
}
/**
* Gets the entity class.
*
* @return string
*/
protected function getEntityClass(): string
{
// removes the suffix "Repository"
$class = preg_replace('/Repository$/', '', static::class);
// replaces "Repository" with "Entity" in the namespace
return str_replace('\\Repository\\', '\\Entity\\', $class);
}
}