Вопрос

I am trying to setup Sluggable from StofDoctrineExtensionsBundle to generate slug based primary key id and name field

/**
 * @var string
 * @Gedmo\Slug(fields={"id","name"})
 * @ORM\Column(name="slug", type="string", length=255, unique=true)
 */
private $slug;

However It doesn't generate like id-name, only generates slug based name. Why does it happen?

Нет правильного решения

Другие советы

If your sluggable listener listens on Doctrine's prePersist operation ...

... then your entity does at that point not have an id because it was not yet persisted.

This explains the missing id in the slug.

Set SluggableListener to postPersist and it will work as desired.

Change Gedmo/Sluggable/SluggableListener's subscribed events to postPersist.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top