$this->em->getRepository(Test::class)->findOneBy(['test' => $test]);
$test = $this->em->getRepository(Test::class)->findOneBy(['test' => $test]);
if (!empty($test)) {
$name = $test->getName();
$surname = $test->getSurname();
}
return $this->render('test/index.html.twig', [
'test' => $test,
'name' => $name ?? null,
'surname' => $surname ?? null
]);
// в твиге
{% if test is not null %}
<div>{{ test.name }}</div>
<div>{{ test.surname }}</div>
{% endif %}
$project = $projectRepository->find($project_id);
if (!$project instanceof Project) {
throw new NotFoundException("Project not found", "project_not_found");
}
// Здесь совершенно точно буддет объект.