doctrine2 sluggable with field with association
doctrine2 sluggable with field with association
我有 ORM:
Something\SomeBundle\Entity\MyTable:
type: entity
table: my_table_name
id:
id:
type: bigint
id: true
generator:
strategy: AUTO
fields:
name:
type: string
length: '64'
nullable: true
slug:
type: string
length: '255'
nullable: true
gedmo:
slug:
separator: -
style: default
updatable: false
fields:
- master
- name
manyToOne:
master:
targetEntity: Master
joinColumn:
name: master_id
referencedColumnName: id
但这不适用于生产环境(错误:无法在实体中找到映射 属性 的 slug [master] - Something\SomeBundle\Entity\MyTable)。为什么?如何解决?
也许这会给你一些线索:
/**
* @ORM\Column(type="string", length=200, nullable=false)
* @Gedmo\Slug(
* fields={"name"},
* handlers={@Gedmo\SlugHandler(
* class="Gedmo\Sluggable\Handler\TreeSlugHandler",
* options={
* @Gedmo\SlugHandlerOption(name="parentRelationField", value="parent"),
* @Gedmo\SlugHandlerOption(name="separator", value="/")
* }
* )}
* )
*/
private $slug;
如果其他人遇到同样的问题,我有解决方案
Something\SomeBundle\Entity\MyTable:
type: entity
table: my_table_name
id:
id:
type: bigint
id: true
generator:
strategy: AUTO
fields:
name:
type: string
length: '64'
nullable: true
slug:
type: string
length: '255'
nullable: true
gedmo:
slug:
handlers:
'Gedmo\Sluggable\Handler\RelativeSlugHandler':
relationField: master
relationSlugField: id
separator: -
separator: -
style: default
updatable: false
fields:
- name
manyToOne:
master:
targetEntity: Master
joinColumn:
name: master_id
referencedColumnName: id
我有 ORM:
Something\SomeBundle\Entity\MyTable:
type: entity
table: my_table_name
id:
id:
type: bigint
id: true
generator:
strategy: AUTO
fields:
name:
type: string
length: '64'
nullable: true
slug:
type: string
length: '255'
nullable: true
gedmo:
slug:
separator: -
style: default
updatable: false
fields:
- master
- name
manyToOne:
master:
targetEntity: Master
joinColumn:
name: master_id
referencedColumnName: id
但这不适用于生产环境(错误:无法在实体中找到映射 属性 的 slug [master] - Something\SomeBundle\Entity\MyTable)。为什么?如何解决?
也许这会给你一些线索:
/**
* @ORM\Column(type="string", length=200, nullable=false)
* @Gedmo\Slug(
* fields={"name"},
* handlers={@Gedmo\SlugHandler(
* class="Gedmo\Sluggable\Handler\TreeSlugHandler",
* options={
* @Gedmo\SlugHandlerOption(name="parentRelationField", value="parent"),
* @Gedmo\SlugHandlerOption(name="separator", value="/")
* }
* )}
* )
*/
private $slug;
如果其他人遇到同样的问题,我有解决方案
Something\SomeBundle\Entity\MyTable:
type: entity
table: my_table_name
id:
id:
type: bigint
id: true
generator:
strategy: AUTO
fields:
name:
type: string
length: '64'
nullable: true
slug:
type: string
length: '255'
nullable: true
gedmo:
slug:
handlers:
'Gedmo\Sluggable\Handler\RelativeSlugHandler':
relationField: master
relationSlugField: id
separator: -
separator: -
style: default
updatable: false
fields:
- name
manyToOne:
master:
targetEntity: Master
joinColumn:
name: master_id
referencedColumnName: id