Updated services required to initialize API keys with roles

This commit is contained in:
Alejandro Celaya
2021-01-10 20:05:14 +01:00
parent 95e51665b1
commit c9ff2b3834
7 changed files with 70 additions and 9 deletions

View File

@@ -45,6 +45,9 @@ class DomainService implements DomainServiceInterface
];
}
/**
* @throws DomainNotFoundException
*/
public function getDomain(string $domainId): Domain
{
/** @var Domain|null $domain */
@@ -55,4 +58,16 @@ class DomainService implements DomainServiceInterface
return $domain;
}
public function getOrCreate(string $authority): Domain
{
$repo = $this->em->getRepository(Domain::class);
/** @var Domain|null $domain */
$domain = $repo->findOneBy(['authority' => $authority]) ?? new Domain($authority);
$this->em->persist($domain);
$this->em->flush();
return $domain;
}
}