I try to get sluggable doctrine extention working on my project. I follow a setup step found on Internet, bu it seems to not working (@Gedmo\Slug seems to be not called/triggered).
The purpuse is to slug a post title.
I'm using Symfony 3.4 and Doctrine 2.3 on PHP 7.1.
Is someone know how to get this work, i would be grateful.
I added the bundle in AppKernel (new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle()
)
Here is my other project files :
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0",
"stof/doctrine-extensions-bundle": "^1.3.0",
"gedmo/doctrine-extensions": "^2.3.4"
},
# Stof\DoctrineExtensionsBundle configuration
stof_doctrine_extensions:
orm:
default:
sluggable: true
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
* @ORM\HasLifecycleCallbacks()
*/
class Advert
{
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var string
*
* @Gedmo\Slug(fields={"title"})
* @ORM\Column(name="slug", type="string", length=255, unique=true, nullable=true)
*/
private $slug;
I just figure out !
I forgot to add the service in my bundle.
So in my services.yml, i add this lines :
gedmo.listener.sluggable:
class: Gedmo\Sluggable\SluggableListener
tags:
- { name: doctrine.event_subscriber, connection: pgsql }
calls:
- [ setAnnotationReader, [ "@annotation_reader" ] ]