Twig 如何使用路由中的参数通过元数据访问保存的实体
我有一个实体联系人Twig 如何使用路由中的参数通过元数据访问保存的实体,twig,entity,symfony4,Twig,Entity,Symfony4,我有一个实体联系人 到目前为止您尝试了什么?我们可以看到您的控制器吗?这是我的控制器中的函数将您的搜索参数传递到存储库$repository->findBy([$routeProperty=>$routeValue])。但是您应该考虑过滤允许的属性以不暴露敏感信息。 /** * @Route("/c00210/readallbyparam/{routeProperty}/{routeValue}", name="c00210_read_all_by_param&q
到目前为止您尝试了什么?我们可以看到您的控制器吗?这是我的控制器中的函数将您的搜索参数传递到存储库$repository->findBy([$routeProperty=>$routeValue])
。但是您应该考虑过滤允许的属性以不暴露敏感信息。
/**
* @Route("/c00210/readallbyparam/{routeProperty}/{routeValue}", name="c00210_read_all_by_param")
*/
public function findAllByparam( $routeProperty,$routeValue)
{
$property = $routeProperty;
$value = $routeValue;
$repository = $this->getDoctrine()->getRepository(Contact::class);
$contacts = $repository->findAll();
return $this->render('c00210/readbycriteria2.html.twig', [
'function' => 'find(<id>)',
'description' => 'finds the with the given Id',
'property' => $property,
'value' => $value,
'contacts' => $contacts,
]);
SELECT * FROM contacts WHERE lastname = 'Mendelsohn'