Skip to content

Extension points

phil/slug-bundle

What an application configures, decorates or relies on. The types are phil/slug's.

Configuration

OptionWhat it extends
sluggersOne slugger per name, each with its locale, max_length and leading_words — see Configuration
defaultWhich named slugger Phil\Slug\Slugger is
historyThe history of former slugs, its connection and its clock — see History of former slugs

Services

ServiceHow an application relies on it
phil_slug.slugger.<name>Decorated by the application, with #[AsDecorator] or decorates:: the decorator takes the place of the slugger in Sluggers, through the aliases and in Twig — see Services
Phil\Slug\SluggerAutowired: the default slugger
Phil\Slug\Slugger $<name>SluggerAutowired by argument name: the slugger of that name
Phil\Slug\SluggersInjected wherever the slugger is chosen at run time; public
Phil\SlugBundle\Application\Contract\SlugHistoryAutowired when the history is enabled: recorded by the code that changes a slug, read by a redirect provider or a controller
phil_slug.historyThe Doctrine history; an application replaces it by aliasing SlugHistory to its own implementation

A bundle that takes a slugger by service id is given phil_slug.slugger.<name>.

SlugHistory

An implementation other than the Doctrine one keeps the contract's invariants:

  • a scope and a subject are checked with SlugHistoryKeys before anything is stored or read;
  • recording a change makes the new slug stop being a former slug of the scope, whichever subject had it, points every former slug of the subject to the new slug, and writes the old slug as a former slug of the subject, all at once;
  • recording a slug as its own former slug changes nothing;
  • formerSlugs() never yields a chain: each value is a current slug;
  • it keeps nothing between two calls, or is tagged kernel.reset.

Twig

The phil_slug filter takes a slugger's name; it uses the same services, decorators included.