2017 © Pedro Peláez
 

library slugifier-api

Provides a basic slugifier interface to transform text into strings suitable for URLs

image

symfony-cmf/slugifier-api

Provides a basic slugifier interface to transform text into strings suitable for URLs

  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 10 % Grown

The README.md

Symfony CMF Slugifier API

Build Status Latest Stable Version Total Downloads, (*1)

This package is part of the Symfony Content Management Framework (CMF) and licensed under the MIT License., (*2)

A "slugifier" is a function which transforms a string such as this into a URL-friendly string such-as-this. Slugifiers are also known as "urlizers"., (*3)

This package does not contain a slugifier implementation, it provides a standard interface (SlugifierInterface) for use by third party slugifiers and a CallbackSlugifier that is capable of wrapping most non-implementing third-party slugifiers to the SlugifierInterface., (*4)

Requirements

Documentation

Perhaps the best way to document this simple component is with a demonstration. You have an event subscriber which slugifies the title of a blog post:, (*5)

<?php

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());
    }
}

You can then inject either a slugifier which already implements the CMF SlugifierInterface or you can use non-implementing libraries using the CallbackSlugifier. Using non-implementing libraries is very easy, assume you want to use the aferrandini/urlizer package (which is also used by the RoutingAutoBundle), you can configure the CallbackSlugifier object to call the Ferrandini\Urlizer::urlize() method:, (*6)

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

By using the Slugifier package you decouple your application from the slugifier implementation., (*7)

See also:, (*8)

FIG Proposal

We proposed this to FIG but unfortunately the proposal did not get enough interest. We would still be happy to contribute this to a PSR should the interest come up and deprecate this package in favor of the PSR one., (*9)

Contributing

Pull requests are welcome. Please see our CONTRIBUTING guide., (*10)

Unit and/or functional tests exist for this bundle. See the Testing documentation for a guide to running the tests., (*11)

Thanks to everyone who has contributed already., (*12)

The Versions

31/07 2017

dev-master

9999999-dev http://cmf.symfony.com

Provides a basic slugifier interface to transform text into strings suitable for URLs

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0

 

The Development Requires

slugify urlize

19/02 2017

2.0.0

2.0.0.0 http://cmf.symfony.com

Provides a basic slugifier interface to transform text into strings suitable for URLs

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0

 

slugify urlize

05/01 2017

2.0.0-RC1

2.0.0.0-RC1 http://cmf.symfony.com

Provides a basic slugifier interface to transform text into strings suitable for URLs

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7.0

 

slugify urlize

31/03 2016

1.0.0

1.0.0.0 http://cmf.symfony.com

Provides a basic slugifier interface to transform text into strings suitable for URLs

  Sources   Download

MIT

The Requires

  • php ^5.3.9|^7.0

 

slugify urlize

01/02 2016

1.0.0-RC1

1.0.0.0-RC1 http://cmf.symfony.com

Provides a basic slugifier interface

  Sources   Download

MIT

The Requires

  • php ^5.3.9|^7.0

 

slugify