Skip to content

Latest commit

 

History

History
28 lines (23 loc) · 934 Bytes

File metadata and controls

28 lines (23 loc) · 934 Bytes

The slug is useful to generate url

use Rami\EntityKitBundle\Common\Interfaces\Slugged\SluggedInterface;
use Rami\EntityKitBundle\Entity\Traits\SluggedTrait;
use Rami\EntityKitBundle\Common\Attributes\Slugged;

#[Slugged(fields: ['title'])]
class Blog implements SluggedInterface 
{
    use SluggedTrait;
    
    #[ORM\Column(...)] <-- Your Mapping
    protected ?string slug = null;
}

if you want the default mapping, use MappedSluggedTrait instead of SluggedTrait and you won't have to define the slug property in your Entity

The attribute has some default params.

fields: [] // An array of fields the entity has for slug generation
ensureUnique: true // True by default. if a slug exists, it appends an incremental number at the end
separator: '-' // defaults to '-'
shouldRegenerateOnUpdate: false // False by default
prefix: string // beginning of the slug
suffix: string // ending of the slug