我试图在Symfony 4应用程序中正确配置Gedmo Sluggable,但失败了。问题是:它不起作用。任何可压缩的列都不会被识别为可压缩的列,并且在保留后保持为空。
composer.json:
"gedmo/doctrine-extensions": "^2.4",
services.yml:
services:
gedmo.listener.sluggable:
class: Gedmo\Sluggable\SluggableListener
tags:
- { name: doctrine.event_subscriber, connection: default, priority: 1 }
calls:
- [ setAnnotationReader, [ '@annotation_reader' ] ]
实体Faculty.orm.yml
:
AppBundle\Entity\Faculty:
type: entity
table: faculty
repositoryClass: AppBundle\Repository\FacultyRepository
id:
id:
type: bigint
generator:
strategy: AUTO
fields:
name:
type: string
column: name
nullable: false
length: 128
slug:
type: string
length: 128
gedmo:
slug:
separator: _
style: camel
updatable: false
fields:
- name
uniqueConstraints:
idx_name:
columns: [ name ]
idx_slug:
columns: [ slug ]
但是,当我保留一个实体时,该子弹保持为空:
$faculty = new Faculty();
$faculty->setName('foobar');
$this->entityManager->persist($faculty);
$this->entityManager->flush();
我错过了什么吗?
我还尝试了this article之后的StofDoctrineExtensionsBundle。没有任何运气。 Sluggable-Listener不会被触发。