class RouterHelper

Methods that may be useful for processing routing activity

Adapted from october\rain\router\Helper

Methods

static string
normalizeUrl(string $url)

Adds leading slash and removes trailing slash from the URL.

static array
segmentizeUrl(string $url)

Splits an URL by segments separated by the slash symbol.

static string
rebuildUrl(array $urlArray)

Rebuilds a URL from an array of segments.

static string
parseValues(stdClass $object, array $columns, string $string)

Replaces :column_name with it's object value. Example: /some/link/:id/:name -> /some/link/1/Joe

static string
replaceParameters(stdClass $object, string $string)

Replaces :column_name with object value without requiring a list of names. Example: /some/link/:id/:name -> /some/link/1/Joe

static bool
segmentIsWildcard(string $segment)

Checks whether an URL pattern segment is a wildcard.

static bool
segmentIsOptional(string $segment)

Checks whether an URL pattern segment is optional.

static string
getParameterName(string $segment)

Extracts the parameter name from a URL pattern segment definition.

static string
getSegmentRegExp(string $segment)

Extracts the regular expression from a URL pattern segment definition.

static string
getSegmentDefaultValue(string $segment)

Extracts the default parameter value from a URL pattern segment definition.

Details

at line 18
static string normalizeUrl(string $url)

Adds leading slash and removes trailing slash from the URL.

Parameters

string $url

URL to normalize.

Return Value

string

Returns normalized URL.

at line 41
static array segmentizeUrl(string $url)

Splits an URL by segments separated by the slash symbol.

Parameters

string $url

URL to segment.

Return Value

array

Returns the URL segments.

at line 62
static string rebuildUrl(array $urlArray)

Rebuilds a URL from an array of segments.

Parameters

array $urlArray

Array the URL segments.

Return Value

string

Returns rebuilt URL.

at line 82
static string parseValues(stdClass $object, array $columns, string $string)

Replaces :column_name with it's object value. Example: /some/link/:id/:name -> /some/link/1/Joe

Parameters

stdClass $object

Object containing the data

array $columns

Expected key names to parse

string $string

URL template

Return Value

string

Built string

at line 110
static string replaceParameters(stdClass $object, string $string)

Replaces :column_name with object value without requiring a list of names. Example: /some/link/:id/:name -> /some/link/1/Joe

Parameters

stdClass $object

Object containing the data

string $string

URL template

Return Value

string

Built string

at line 124
static bool segmentIsWildcard(string $segment)

Checks whether an URL pattern segment is a wildcard.

Parameters

string $segment

The segment definition.

Return Value

bool

Returns boolean true if the segment is a wildcard. Returns false otherwise.

at line 134
static bool segmentIsOptional(string $segment)

Checks whether an URL pattern segment is optional.

Parameters

string $segment

The segment definition.

Return Value

bool

Returns boolean true if the segment is optional. Returns false otherwise.

at line 160
static string getParameterName(string $segment)

Extracts the parameter name from a URL pattern segment definition.

Parameters

string $segment

The segment definition.

Return Value

string

Returns the segment name.

at line 200
static string getSegmentRegExp(string $segment)

Extracts the regular expression from a URL pattern segment definition.

Parameters

string $segment

The segment definition.

Return Value

string

Returns the regular expression string or false if the expression is not defined.

at line 219
static string getSegmentDefaultValue(string $segment)

Extracts the default parameter value from a URL pattern segment definition.

Parameters

string $segment

The segment definition.

Return Value

string

Returns the default value if it is provided. Returns false otherwise.