当尝试使用@Gedmo \ Timestampable(on =“create”)注释创建实体时,我收到“SQLSTATE [23000]:完整性约束违规:1048列'已创建'不能为空”
它也不适用于Gedmo \ Slug。
在使用默认实体管理器时有效,但在使用master或创建时则无效。
在我的config.yml中,我有以下配置:
stof_doctrine_extensions:
default_locale: en
translation_fallback: true
orm:
default:
timestampable: true
sluggable: true
master:
timestampable: true
sluggable: true
creation:
timestampable: true
sluggable: true
在我的services.yml中,我有以下内容:
gedmo.listener.timestampable:
class: Gedmo\Timestampable\TimestampableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
- { name: doctrine.event_subscriber, connection: creation }
- { name: doctrine.event_subscriber, connection: master }
calls:
- [ setAnnotationReader, [ @annotation_reader ] ]
gedmo.listener.sluggable:
class: Gedmo\Sluggable\SluggableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
- { name: doctrine.event_subscriber, connection: master }
- { name: doctrine.event_subscriber, connection: creation }
calls:
- [ setAnnotationReader, [ @annotation_reader ] ]
似乎event_subscriber无法正常工作。
我正在使用StofDoctrineExtensionsBundle运行Symfony 2.3.2。
创建slug的实体有:
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var string
* @Gedmo\Slug(fields={"title"})
* @ORM\Column(name="slug", type="string", length=255, unique=true)
*/
private $slug;
创建的实体具有:
/**
* @var \DateTime
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created", type="datetime")
*/
private $created;
有什么想法吗?