1

我有 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

但这在 prod 环境中不起作用(错误:无法找到 slug [master] 作为实体中的映射属性 - Something\SomeBundle\Entity\MyTable)。为什么?如何解决?

4

2 回答 2

2

如果其他人有同样的问题,我有一个解决方案

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
于 2016-04-11T19:04:22.593 回答
1

也许这会给你一些线索:

/**
 * @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;
于 2016-04-10T08:48:06.663 回答