I'm trying to access a repository from a service, the repository works perfectly, I can use it from a controller, but not from a service.
Basically I have the following code:
namespace App\Service;
use App\Entity\Credencial;
use App\Repository\CredencialRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
class Authentication extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Credencial::class);
}
public function auth(string $key): string
{
$qb = $this->createQueryBuilder('c')
->andWhere('c.credencialKey = :key')
->setParameter('key', 'teste_key')
->getQuery();
$credencial = $qb->setMaxResults(1)->getOneOrNullResult();
return $credencial->execute();
}
}
This is the last thing I tried, I was trying to query without the repository, but didn't work either.
I didn't touch the service.yaml or other config file.