我有以下实体
use Gedmo\Timestampable\Traits\TimestampableEntity;
/**
* @ORM\Entity
* @ORM\Table(name="users")
* @UniqueEntity(fields="email", message="Email already taken")
*/
class User
{
/**
* Hook timestampable behavior
* updates createdAt, updatedAt fields
*/
use TimestampableEntity;
...
如果我跑
$ php app/console doctrine:mapping:info
我收到此错误
found 8 mapped entities:
[OK] Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation
[OK] Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation
[OK] Gedmo\Translatable\Entity\Translation
[OK] Gedmo\Loggable\Entity\MappedSuperclass\AbstractLogEntry
[OK] Gedmo\Loggable\Entity\LogEntry
[OK] Gedmo\Tree\Entity\MappedSuperclass\AbstractClosure
[OK] Psren\CmsBundle\Entity\Group
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@Gedmo\Timestampable" in property Psren\CmsBundle\Entity\User::$createdAt was never imported. Did you maybe forget to add a "use" statement for this annotation?
注释@Gedmo \ Timestampable是在扩展的特征中定义的。所以它必须已被加载。
出了什么问题? 谢谢你的帮助。答案 0 :(得分:2)
: - )
我忘了加载注释。
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;
/**
* @ORM\Entity
* @ORM\Table(name="users")
* @UniqueEntity(fields="email", message="Email already taken")
*/
class User
{
/**
* Hook timestampable behavior
* updates createdAt, updatedAt fields
*/
use TimestampableEntity;