PHP code example of symfony-cmf / slugifier-api

1. Go to this page and download the library: Download symfony-cmf/slugifier-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

symfony-cmf / slugifier-api example snippets




use Symfony\Cmf\Api\Slugifier\SlugifierInterface;

class FooSubscriber
{
    private $slugifier;

    public function __construct(SlugifierInterface $slugifier)
    {
        $this->slugifier = $slugifier;
    }

    public function onEntitySave(\Some\Event $event)
    {
         $entity = $event->getEntity();
         $entity->setSlug($this->slugifier->slugify($entity->getTitle());
    }
}

$slugifier = new CallbackSlugifier('Ferrandini\Urlizer::urlize');
$fooSubscriber = new FooSubscriber($slugifier);