Overview

Namespaces

  • Charcoal
    • Object
    • User
      • Acl

Classes

  • Content
  • ObjectRevision
  • ObjectRoute
  • ObjectSchedule
  • UserData

Interfaces

  • ArchivableInterface
  • CategorizableInterface
  • CategorizableMultipleInterface
  • CategoryInterface
  • ContentInterface
  • HierarchicalInterface
  • ObjectRevisionInterface
  • ObjectRouteInterface
  • ObjectScheduleInterface
  • PublishableInterface
  • RevisionableInterface
  • RoutableInterface
  • UserDataInterface

Traits

  • ArchivableTrait
  • CategorizableMultipleTrait
  • CategorizableTrait
  • CategoryTrait
  • HierarchicalTrait
  • PublishableTrait
  • RevisionableTrait
  • RoutableTrait
  • Overview
  • Namespace
  • Class

Trait RoutableTrait

Full implementation, as Trait, of the Charcoal\Object\RoutableInterface.

This implementation uses a secondary model, Charcoal\Object\ObjectRoute, to collect all routes of routable models under a single source.

Namespace: Charcoal\Object
Located at Charcoal/Object/RoutableTrait.php
Methods summary
public Charcoal\Object\RoutableInterface
# setSlugPattern( mixed $pattern )

Set the object's URL slug pattern.

Set the object's URL slug pattern.

Parameters

$pattern
The slug pattern.

Returns

Charcoal\Object\RoutableInterface
Chainable
public Charcoal\Translation\TranslationString|null
# slugPattern( )

Retrieve the object's URL slug pattern.

Retrieve the object's URL slug pattern.

Returns

Charcoal\Translation\TranslationString|null

Throws

InvalidArgumentException
If a slug pattern is not defined.
public Charcoal\Translation\TranslationString|null
# slugPrefix( )

Retrieve route prefix for the object's URL slug pattern.

Retrieve route prefix for the object's URL slug pattern.

Returns

Charcoal\Translation\TranslationString|null
public Charcoal\Translation\TranslationString|null
# slugSuffix( )

Retrieve route suffix for the object's URL slug pattern.

Retrieve route suffix for the object's URL slug pattern.

Returns

Charcoal\Translation\TranslationString|null
public boolean
# isSlugEditable( )

Determine if the slug is editable.

Determine if the slug is editable.

Returns

boolean
public Charcoal\Object\RoutableInterface
# setSlug( mixed $slug )

Set the object's URL slug.

Set the object's URL slug.

Parameters

$slug
The slug.

Returns

Charcoal\Object\RoutableInterface
Chainable
public Charcoal\Translation\TranslationString|null
# slug( )

Retrieve the object's URL slug.

Retrieve the object's URL slug.

Returns

Charcoal\Translation\TranslationString|null
public Charcoal\Translation\TranslationString
# generateSlug( )

Generate a URL slug from the object's URL slug pattern.

Generate a URL slug from the object's URL slug pattern.

Returns

Charcoal\Translation\TranslationString

Throws

UnexpectedValueException
If the slug is empty.
protected string
# generateRoutePattern( string $pattern )

Generate a route from the given pattern.

Generate a route from the given pattern.

Parameters

$pattern
The slug pattern.

Returns

string
Returns the generated route.

Uses

Charcoal\Object\RoutableTrait::parseRouteToken()
If a view renderer is unavailable.
protected string
# parseRouteToken( string|array $token )

Parse the given slug (URI token) for the current object.

Parse the given slug (URI token) for the current object.

Parameters

$token
The token to parse relative to the model entry.

Returns

string

Throws

InvalidArgumentException
If a route token is not a string.

Uses

Charcoal\Object\RoutableTrait::filterRouteToken()
For customize the route value filtering,

Used by

Charcoal\Object\RoutableTrait::generateRoutePattern()
If a view renderer is unavailable.

Used-by

self::generateRoutePattern() If a view renderer is unavailable.
protected string
# filterRouteToken( mixed $value, string $token = null )

Filter the given value for a URI.

Filter the given value for a URI.

Parameters

$value
A value to filter.
$token
The parsed token.

Returns

string
The filtered $value.

Used by

Charcoal\Object\RoutableTrait::parseRouteToken()
For customize the route value filtering,

Used-by

self::parseRouteToken() To resolve the token's value.
protected
# generateObjectRoute( mixed $slug = null )

Route generation.

Route generation.

Saves all routes to Charcoal\Object\ObjectRoute.

Parameters

$slug
Slug by langs.
protected Charcoal\Object\ObjectRouteInterface
# getLatestObjectRoute( string|null $lang = null )

Retrieve the latest object route.

Retrieve the latest object route.

Parameters

$lang
If object is multilingual, return the object route for the specified locale.

Returns

Charcoal\Object\ObjectRouteInterface
Latest object route.

Throws

InvalidArgumentException
If the given language is invalid.
public Charcoal\Translation\TranslationString|string
# url( string|null $lang = null )

Retrieve the object's URI.

Retrieve the object's URI.

Parameters

$lang
If object is multilingual, return the object route for the specified locale.

Returns

Charcoal\Translation\TranslationString|string
public string
# slugify( string $str )

Convert a string into a slug.

Convert a string into a slug.

Parameters

$str
The string to slugify.

Returns

string
The slugified string.
protected string
# finalizeSlug( string $slug )

Finalize slug.

Finalize slug.

Adds any prefix and suffix defined in the routable configuration set.

Parameters

$slug
A slug.

Returns

string

Throws

UnexpectedValueException
If the slug affixes are invalid.
protected boolean
# deleteObjectRoutes( )

Delete all object routes.

Delete all object routes.

Should be called on object deletion \Charcoal\Model\AbstractModel::preDelete().

Returns

boolean
Success or failure.
public Charcoal\Object\ObjectRouteInterface
# createRouteObject( )

Create a route object.

Create a route object.

Returns

Charcoal\Object\ObjectRouteInterface
protected AbstractPropertyDisplay
# setObjectRouteClass( string $className )

Set the class name of the object route model.

Set the class name of the object route model.

Parameters

$className
The class name of the object route model.

Returns

AbstractPropertyDisplay
Chainable

Throws

InvalidArgumentException
If the class name is not a string.
public string
# objectRouteClass( )

Retrieve the class name of the object route model.

Retrieve the class name of the object route model.

Returns

string
abstract public Charcoal\Factory\FactoryInterface
# modelFactory( )

Retrieve the object model factory.

Retrieve the object model factory.

Returns

Charcoal\Factory\FactoryInterface
abstract public mixed
# templateIdent( )

Retrieve the routable object's template identifier.

Retrieve the routable object's template identifier.

Returns

mixed
Properties summary
protected Charcoal\Translation\TranslationString|string|null $slug

The object's route.

The object's route.

#
API documentation generated by ApiGen