Symfony 关于 ParamConverter 的手册有这个例子:
/**
* @Route("/blog/{post_id}")
* @Entity("post", expr="repository.find(post_id)")
*/
public function showAction(Post $post)
{
}
但是使用@Entity 注释给我这个错误。
The annotation "@Entity" in method AppBundle\Controller\CurrencyController::currencyAction() was never imported. Did you maybe forget to add a "use" statement for this annotation?
很明显,我需要使用命名空间,但是哪个呢?请帮忙。
最佳答案
Entity
注释仅存在于 master(或 futur v4)上。
Source file here
但是如您所见,这只是带有 expr
选项的 @ParamConverter 注释的快捷方式,因此您必须在下一个版本之前使用它。
最好的问候。
关于php - Symfony2 - 如何在 Controller 中使用@Entity 注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42132616/