<?php
namespace BigIdea\IdentityBundle\Repository;
use BigIdea\IdentityBundle\Entity\TeamMate;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectRepository;
class TeamMateRepository
{
private ObjectManager $objectManager;
public function __construct(ManagerRegistry $registry)
{
$this->objectManager = $registry->getManagerForClass(TeamMate::class);
}
private function getRepository(): ObjectRepository
{
return $this->objectManager->getRepository(TeamMate::class);
}
public function findBySsoIdentifier(string $ssoIdentifier): ?TeamMate
{
return $this->getRepository()->findOneBy(['ssoIdentifier' => $ssoIdentifier]);
}
public function findByEmail(string $email): ?TeamMate
{
return $this->getRepository()->findOneBy(['email' => $email]);
}
public function save(TeamMate $teamUser): void
{
$this->objectManager->persist($teamUser);
$this->objectManager->flush();
}
}