-1

I don't understand how to set up the slug with A2lix. Can someone tell me the procedure or a tutorial that could help me? This would be very nice.

I try to use @Gedmo\Slug, but I don't know how to make the route with slug data into the controller.

I also tried KnpLabs/DoctrineBehaviors without more success

My config:

symfony : 3.1
knplabs/doctrine-behaviors: "@stable",
a2lix/i18n-doctrine-bundle": "@stable",
a2lix/auto-form-bundle: "0.x@dev",
a2lix/translation-form-bundle": "3.x@dev",
stof/doctrine-extensions-bundle": "^1.2.2",

Thank you for your help

Chetan Ameta
  • 7,696
  • 3
  • 29
  • 44
Na Ba
  • 15
  • 4

1 Answers1

0

Add this annotation to your field in your entity :

@Gedmo\Slug(fields={"the_field_you_want_to_slugify"})

Ex: you have a title and you want to slugify it

/**
 * @ORM\Column(type="string")
 * @Gedmo\Slug(fields={"title"})
 */
protected $slug;

and don't forget :

use Gedmo\Mapping\Annotation as Gedmo;

And finally in services.yml put this:

gedmo.listener.sluggable:
   class: Gedmo\Sluggable\SluggableListener
   tags:
      - { name: doctrine.event_subscriber, connection: default }
   calls:
      - [ setAnnotationReader, [ "@annotation_reader" ] ]