【发布时间】:2016-10-06 13:31:35
【问题描述】:
我尝试通过gedmo 扩展名使用教义扩展sortable。我用 composer 安装了 gedmo-package 并按照 the installation in symfony2 的说明进行操作。我使用yaml-files 作为学说的映射信息。
我的 yaml 文件:
AppBundle\Entity\Picture:
type: entity
table: pictures
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
[...]
type:
type: string
length: 20
position:
type: string
gedmo:
sortable:
groups: [type]
字段位置确实有 int 类型,但我也尝试了 string,因为这会导致可排序扩展 (InvalidMappingException) 的 yaml 驱动程序出错。
但我总是得到的错误是Integrity constraint violation: 19 NOT NULL constraint failed: pictures.position。但在所有可排序扩展的 examples 中,无需专门为位置字段设置值或在 yaml 文件中允许为空。我还想,InvalidMappingException 应该出现在NOT NULL Exception 之前。
因此,我认为甚至没有使用扩展名。 我使用的配置文件:
我的 config.yml 文件:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: doctrine_extensions.yml}
[...]
我的学说_extensions.yml 文件:
services:
# KernelRequest listener
gedmo.listener.sortable:
class: Gedmo\Sortable\SortableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ "@annotation_reader" ] ]
【问题讨论】:
标签: doctrine-orm symfony doctrine-extensions