问题
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