gpt4 book ai didi

php - Symfony2 - 如何在 Controller 中使用@Entity 注释?

转载 作者:可可西里 更新时间:2023-10-31 22:51:19 26 4
gpt4 key购买 nike

Symfony 关于 ParamConverter 的手册有这个例子:

/**
* @Route("/blog/{post_id}")
* @Entity("post", expr="repository.find(post_id)")
*/
public function showAction(Post $post)
{
}

来源:http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#fetch-via-an-expression

但是使用@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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com