symfony 从控制器中的另一个属性访问属性

qybjjes1  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(187)

我正在Symfony中构建一个Web应用程序,我需要访问控制器中某个实体的一些属性,以便将这些值添加到$candidature实体中。谢谢您的帮助。
控制器. php:

class CandidatureController extends AbstractController
{
#[Route('/candidature', name: 'app_candidature')]
public function index(EntityManagerInterface $entityManager): Response
{
    $candidature = new Candidature();

    //$candidatNom = $entityManager->getRepository(ProfileCandidat::class)->findBy($Nom);

    $candidature->setNom($candidatNom);
    $candidature->setPrenom('Charles');
    $candidature->setCv('cv');
    $candidature->setPostId('4');

    $entityManager->persist($candidature);
    $entityManager->flush();
    return $this->render('candidature/index.html.twig', [
        'controller_name' => 'CandidatureController',
    ]);
}
}
djmepvbi

djmepvbi1#

$candidatNom = $entityManager->getRepository(ProfileCandidat::class)->findBy(['nom' => $Nom);

应该可以

相关问题