class PermalinkMaker

Traits

Singleton trait.

Properties

static protected $instance from  Singleton
protected Model $model

Methods

static 
instance()

Create a new instance of this singleton.

static 
forgetInstance()

Forget this singleton's instance if it exists

__construct()

Constructor.

initialize()

Initialize the singleton free from constructor parameters.

__clone()

No description

__wakeup()

No description

slug(Model $model, $force = false)

No description

array
getConfiguration(array $overrides = [])

Get the permalink configuration for the current model, including default values that where not specified.

null|string
buildSlug(string $attribute, array $config, bool $force = null)

Build the slug for the given attribute of the current model.

bool
needsSlugging(string $attribute, array $config)

Determines whether the model needs slugging.

mixed|string
getSlugSource($from)

Get the string that should be used as base for the slug.

string
generateSlug(string $source, array $config, string $attribute)

Generate a slug from the given source string.

string
makeSlugUnique(string $slug, array $config, string $attribute)

Checks if the slug should be unique, and makes it so if needed.

Collection
getExistingSlugs(string $slug, string $attribute, array $config)

Get all existing slugs that are similar to the given slug.

string
validateSlug(string $slug, array $config, string $attribute)

Checks that the given slug is not a reserved word.

string
generateSuffix(string $slug, string $separator, Collection $list)

Generate a unique suffix for the given slug (and list of existing, "similar" slugs.

setModel(Model $model)

No description

Details

in Singleton at line 18
final static instance()

Create a new instance of this singleton.

in Singleton at line 28
final static forgetInstance()

Forget this singleton's instance if it exists

in Singleton at line 36
final protected __construct()

Constructor.

in Singleton at line 44
protected initialize()

Initialize the singleton free from constructor parameters.

in Singleton at line 48
__clone()

No description

in Singleton at line 53
__wakeup()

No description

at line 15
slug(Model $model, $force = false)

No description

Parameters

Model $model
$force

at line 39
array getConfiguration(array $overrides = [])

Get the permalink configuration for the current model, including default values that where not specified.

Parameters

array $overrides

Return Value

array

at line 72
null|string buildSlug(string $attribute, array $config, bool $force = null)

Build the slug for the given attribute of the current model.

Parameters

string $attribute
array $config
bool $force

Return Value

null|string

at line 98
protected bool needsSlugging(string $attribute, array $config)

Determines whether the model needs slugging.

Parameters

string $attribute
array $config

Return Value

bool

at line 118
protected mixed|string getSlugSource($from)

Get the string that should be used as base for the slug.

Parameters

$from

Return Value

mixed|string

at line 146
protected string generateSlug(string $source, array $config, string $attribute)

Generate a slug from the given source string.

Parameters

string $source
array $config
string $attribute

Return Value

string

at line 170
protected string makeSlugUnique(string $slug, array $config, string $attribute)

Checks if the slug should be unique, and makes it so if needed.

Parameters

string $slug
array $config
string $attribute

Return Value

string

Exceptions

UnexpectedValueException

at line 211
protected Collection getExistingSlugs(string $slug, string $attribute, array $config)

Get all existing slugs that are similar to the given slug.

Parameters

string $slug
string $attribute
array $config

Return Value

Collection

at line 240
protected string validateSlug(string $slug, array $config, string $attribute)

Checks that the given slug is not a reserved word.

Parameters

string $slug
array $config
string $attribute

Return Value

string

at line 284
protected string generateSuffix(string $slug, string $separator, Collection $list)

Generate a unique suffix for the given slug (and list of existing, "similar" slugs.

Parameters

string $slug
string $separator
Collection $list

Return Value

string

at line 304
setModel(Model $model)

No description

Parameters

Model $model