Helper
Methods that may be useful for processing routing activity
class Winter\Storm\Router\Helper
Methods
public static getParameterName (string $segment) : string
Extracts the parameter name from a URL pattern segment definition.
Property | Type | Description |
---|---|---|
$segment | string |
string
The segment definition. |
Returns the segment name.
public static getSegmentDefaultValue (string $segment) : string | false
Extracts the default parameter value from a URL pattern segment definition.
Property | Type | Description |
---|---|---|
$segment | string |
string
The segment definition. |
Returns the default value if it is provided. Returns false otherwise.
public static getSegmentRegExp (string $segment) : string | false
Extracts the regular expression from a URL pattern segment definition.
Property | Type | Description |
---|---|---|
$segment | string |
string
The segment definition. |
Returns the regular expression string or false if the expression is not defined.
public static normalizeUrl (string $url) : string
Adds leading slash and removes trailing slash from the URL.
Property | Type | Description |
---|---|---|
$url | string |
string
URL to normalize. |
Returns normalized URL.
public static parseValues (object | array $object, array $columns, string $string) : string
Replaces :column_name with it's object value. Example: /some/link/:id/:name -> /some/link/1/Joe
Property | Type | Description |
---|---|---|
$object | object | array |
object | array
Object containing the data |
$columns | array |
array
Expected key names to parse |
$string | string |
string
URL template |
Built string
public static rebuildUrl (array $urlArray) : string
Rebuilds a URL from an array of segments.
Property | Type | Description |
---|---|---|
$urlArray | array |
array
Array the URL segments. |
Returns rebuilt URL.
public static replaceParameters (object | array $object, string $string) : string
Replaces :column_name with object value without requiring a list of names. Example: /some/link/:id/:name -> /some/link/1/Joe
Property | Type | Description |
---|---|---|
$object | object | array |
object | array
Object containing the data |
$string | string |
string
URL template |
Built string
public static segmentIsOptional (string $segment) : bool
Checks whether an URL pattern segment is optional.
Property | Type | Description |
---|---|---|
$segment | string |
string
The segment definition. |
Returns boolean true if the segment is optional. Returns false otherwise.
public static segmentIsWildcard (string $segment) : bool
Checks whether an URL pattern segment is a wildcard.
Property | Type | Description |
---|---|---|
$segment | string |
string
The segment definition. |
Returns boolean true if the segment is a wildcard. Returns false otherwise.
public static segmentizeUrl (string $url) : array
Splits an URL by segments separated by the slash symbol.
Property | Type | Description |
---|---|---|
$url | string |
string
URL to segmentize. |
Returns the URL segments.