Symfony2 “@Type” in property Genius\ProfileBundle\Entity\Profil::$actualites was never imported [closed]

让人想犯罪 __ 提交于 2019-12-13 22:01:18

问题


I am new to Symfony2 in general. This issue relates to JMS Serializer annotations and FOSRestBundle though.

I have the following Profile.php Entity with an Actualite Field that i'm looking to set them as an Array through Type Annotation.

class Profile  {
...

     /**
     * @ORM\OneToMany(targetEntity="Genius\ProfileBundle\Entity\Actualite", mappedBy="profil",cascade={"persist"}, cascade={"persist", "remove"})
     */


     /**
     * @Type("array<Actualite>")
     */
    private $actualites;
...
}

But i'm getting the following error :

"@Type" in property Genius\ProfileBundle\Entity\Profil::$actualites was never imported.

To solve the problem i had add the following line but the problem still :

use Genius\ProfileBundle\Entity\Actualite;

回答1:


Have you insert this "use" in your Profile entity ?

use JMS\Serializer\Annotation\Type;

EDIT :

You have set your

@Type("array<Actualie>")

But I think it's

@Type("array<Actualite>")


来源:https://stackoverflow.com/questions/23604616/symfony2-type-in-property-genius-profilebundle-entity-profilactualites-was

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!