RouteGroup
in package
Route group attribute for defining shared settings for all routes in a controller.
This attribute is applied at the class level and affects all route attributes within that controller. It allows you to define common prefixes and filters that will be inherited by all routes.
Tags
Attributes
- #[Attribute]
- \Attribute::TARGET_CLASS
Table of Contents
Properties
Methods
- __construct() : mixed
- applyPrefix() : string
- Apply group settings to a route path
- getFilters() : array<string|int, mixed>
- Get the group filters
- getPrefix() : string
- Get the route prefix
- mergeFilters() : array<string|int, mixed>
- Merge group filters with route filters
Properties
$filters read-only
public
array<string|int, mixed>
$filters
= []
$prefix read-only
public
string
$prefix
= ''
Methods
__construct()
public
__construct([string $prefix = '' ][, array<string|int, mixed> $filters = [] ]) : mixed
Parameters
- $prefix : string = ''
-
Path prefix to prepend to all routes (e.g., '/admin')
- $filters : array<string|int, mixed> = []
-
Filters to apply to all routes in this group
applyPrefix()
Apply group settings to a route path
public
applyPrefix(string $routePath) : string
Parameters
- $routePath : string
-
The route path from the method attribute
Return values
string —The full path with prefix applied
getFilters()
Get the group filters
public
getFilters() : array<string|int, mixed>
Return values
array<string|int, mixed>getPrefix()
Get the route prefix
public
getPrefix() : string
Return values
stringmergeFilters()
Merge group filters with route filters
public
mergeFilters(array<string|int, mixed> $routeFilters) : array<string|int, mixed>
Parameters
- $routeFilters : array<string|int, mixed>
-
Filters from the route attribute
Return values
array<string|int, mixed> —Combined filters (group filters first, then route filters)