Search code examples
symfonydoctrineslug

Trigger Slug with symfony


I am working with Symfony, and I am trying to slug some element of my database using Doctrine's extension Gedmo. The issue is that I initialize my database with a sql script, so I dont trigger the generation of the slug by Doctrine.

I would like to know if there is a clean way to generate it. For instance:

public function getSlug(){
    if(empty($this->slug)){
       $this->slug=generateSlug();
    }
    return $this->slug;
;

I could not find any solution.

Thanks.


Solution

  • From the sluggable readme: https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/sluggable.md

    Update 2013-08-19

    allow empty slug #807 regenerate slug only if set to null

    so:

    1. Fetch your entities
    2. Set their slug to null
    3. Flush

    And you are done !