October\Rain\Router\Helper

Overview

Helper methods that may be useful for processing routing activity


Public Methods

public static getParameterName()

public static getParameterName(string $segment): string 

getParameterName extracts the parameter name from a URL pattern segment definition.

public static getSegmentDefaultValue()

public static getSegmentDefaultValue(string $segment): string 

getSegmentDefaultValue extracts the default parameter value from a URL pattern segment definition.

public static getSegmentRegExp()

public static getSegmentRegExp(string $segment): string 

getSegmentRegExp extracts the regular expression from a URL pattern segment definition.

public static normalizeUrl()

public static normalizeUrl(string $url): string 

normalizeUrl adds leading slash and removes trailing slash from the URL.

public static parseValues()

public static parseValues(
    stdObject $object,
    array $columns,
    string $string
): string 

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

public static rebuildUrl()

public static rebuildUrl(array $urlArray): string 

rebuildUrl from an array of segments.

public static replaceParameters()

public static replaceParameters(
    stdObject $object,
    string $string
): string 

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

public static segmentIsOptional()

public static segmentIsOptional(string $segment): boolean 

segmentIsOptional checks whether an URL pattern segment is optional.

public static segmentIsWildcard()

public static segmentIsWildcard(string $segment): boolean 

segmentIsWildcard checks whether an URL pattern segment is a wildcard.

public static segmentizeUrl()

public static segmentizeUrl(string $url, bool $pattern = true): array 

segmentizeUrl splits a URL by segments separated by the slash symbol and returns the URL segments. Using a pattern includes regex support in the URL.

public static validateUrl()

public static validateUrl($url): bool 

validateUrl checks if the URL pattern provided is valid for parsing