Rule

Router Rule Object

 class Winter\Storm\Router\Rule

Properties

public $dynamicSegmentCount : int

The number of dynamic segments found in the pattern

public $segments : array

Pattern segments

public $staticSegmentCount : int

The number of static segments found in the pattern

public $staticUrl : string

URL with static segments only, dynamic segments are stripped

public $wildSegmentCount : int

The number of wildcard segments found in the pattern

protected $afterMatchCallback : callable

Called when this rule is matched.

protected $conditionCallback : callable

Custom condition used when matching this rule.

protected $ruleName : string

A named reference for this rule.

protected $rulePattern : string

The pattern used to match this rule.

Methods

public __construct (string $name, string $pattern)

Creates a new router rule instance.

Parameters
Property Description
$name
string
$pattern
string
Returns
mixed

public afterMatch (callable $callback = null) : callable

After match callback

Parameters
Property Description
$callback
callable

Callback function to be used to modify params after a successful match

Returns
callable

public condition (callable $callback = null) : callable

Condition callback

Parameters
Property Description
$callback
callable

Callback function to be used when providing custom route match conditions

Returns
callable

public name (string $name = null) : object | string

Unique route name

This is a getter and setter method.

Parameters
Property Description
$name
string

Unique name for the router object

Returns
object | string

public pattern (string $pattern = null) : object | string

Route match pattern

This is a getter and setter method.

Parameters
Property Description
$pattern
string

Pattern used to match this rule

Returns
object | string

public resolveUrl (string $url, array $parameters) : bool

Checks whether a given URL matches a given pattern.

Parameters
Property Description
$url
string

The URL to check.

$parameters
array

A reference to a PHP array variable to return the parameter list fetched from URL.

Returns
bool

Returns true if the URL matches the pattern. Otherwise returns false.

protected captureWildcardSegments (array $urlSegments) : array

Captures and removes every segment of a URL after a wildcard pattern segment is detected, until both collections of segments are the same size.

Parameters
Property Description
$urlSegments
array
Returns
array
Copyright © 2024 Winter CMS