SlugService
in package
Slug Service - Replaces QubitSlug.
Provides slug generation and management. Maintains full compatibility with AtoM's slug patterns.
Tags
Table of Contents
Constants
- SLUG_BASIS_IDENTIFIER = 1
- SLUG_BASIS_REFERENCE_CODE = 2
- SLUG_BASIS_TITLE = 0
- Slug basis constants (from QubitSlug).
- SLUG_PERMISSIVE = 1
- SLUG_RESTRICTIVE = 0
- TABLE_NAME = 'slug'
- Table name constant (replaces QubitSlug::TABLE_NAME).
Methods
- createSlug() : object
- Create slug for object.
- deleteSlug() : bool
- Delete slug for object.
- generateSlug() : string
- Generate unique slug from string.
- getByObjectId() : object|null
- Get slug by object ID.
- getBySlug() : object|null
- Get object ID by slug.
- getSlugBasis() : int
- Get slug basis setting.
- getValidSlugChars() : string
- Get valid slug characters for regex (replaces QubitSlug::getValidSlugChars).
- isPermissive() : bool
- Check if permissive slug creation is enabled.
- slugExists() : bool
- Check if slug exists.
- slugify() : string
- Convert string to URL-safe slug.
- updateSlug() : bool
- Update slug for object.
Constants
SLUG_BASIS_IDENTIFIER
public
mixed
SLUG_BASIS_IDENTIFIER
= 1
SLUG_BASIS_REFERENCE_CODE
public
mixed
SLUG_BASIS_REFERENCE_CODE
= 2
SLUG_BASIS_TITLE
Slug basis constants (from QubitSlug).
public
mixed
SLUG_BASIS_TITLE
= 0
SLUG_PERMISSIVE
public
mixed
SLUG_PERMISSIVE
= 1
SLUG_RESTRICTIVE
public
mixed
SLUG_RESTRICTIVE
= 0
TABLE_NAME
Table name constant (replaces QubitSlug::TABLE_NAME).
public
mixed
TABLE_NAME
= 'slug'
Methods
createSlug()
Create slug for object.
public
static createSlug(int $objectId, string $string) : object
Parameters
- $objectId : int
- $string : string
Return values
objectdeleteSlug()
Delete slug for object.
public
static deleteSlug(int $objectId) : bool
Parameters
- $objectId : int
Return values
boolgenerateSlug()
Generate unique slug from string.
public
static generateSlug(string $string[, int $objectId = null ]) : string
Parameters
- $string : string
- $objectId : int = null
Return values
stringgetByObjectId()
Get slug by object ID.
public
static getByObjectId(int $objectId) : object|null
Replaces: QubitSlug::getByObjectId($id)
Parameters
- $objectId : int
Return values
object|nullgetBySlug()
Get object ID by slug.
public
static getBySlug(string $slug) : object|null
Replaces: QubitSlug::getBySlug($slug)
Parameters
- $slug : string
Return values
object|nullgetSlugBasis()
Get slug basis setting.
public
static getSlugBasis() : int
Return values
intgetValidSlugChars()
Get valid slug characters for regex (replaces QubitSlug::getValidSlugChars).
public
static getValidSlugChars() : string
Return values
stringisPermissive()
Check if permissive slug creation is enabled.
public
static isPermissive() : bool
Return values
boolslugExists()
Check if slug exists.
public
static slugExists(string $slug[, int|null $excludeObjectId = null ]) : bool
Parameters
- $slug : string
- $excludeObjectId : int|null = null
Return values
boolslugify()
Convert string to URL-safe slug.
public
static slugify(string $string) : string
Parameters
- $string : string
Return values
stringupdateSlug()
Update slug for object.
public
static updateSlug(int $objectId, string $newSlug) : bool
Parameters
- $objectId : int
- $newSlug : string