I need some help.
I have a DomainController
which I use to define some Propertys
and create a Domain Entity
public function new(Request $request): Response{
$data = json_decode($request->getContent(), true);
$domain = new Domain();
$domain->setUri($data['record']['uri']);
$em = $this->getDoctrine()->getManager();
$em->persist($domain);
$em->flush($domain);
$id = $domain->getId();
$uri = $domain->getUri();
$businessRepository = new BusinessRepository();
$result = $businessRepository->newDomainCheck($id, $uri);
return new JsonResponse($result);
}
You can see, that I call my BusinessRepository->newDomainCheck($id, $uri)
Problem:
My $id variable is empty, but i need this int after flushing.
public function newDomainCheck($id, $uri){
var_dump($id);
var_dump($uri);
$domain = new Domain();
$domain->setUri($uri);
$domain->setId($id);
$result = $this->analyzeDomain($uri);
$res = json_decode($result->getContent(), true);
$domainCheckResult = $this->createResponse($res, $domain);
$em = $this
->getEntityManager()
->getRepository('App:DomainCheckResult');
$em->persist($domainCheckResult);
$em->flush($domainCheckResult);
return new JsonResponse($domainCheckResult);
}
Problem:
Attempted to call undefined method named "getEntityManager" of class "App\Repository\BusinessRepository"
Can you help me, to solve this?