class vB5_Template_Url

Constants

PLACEHOLDER_PREFIX

PLACEHOLDER_SUFIX

Properties

static protected vB5_Template_Url $instance Singleton instance of this class.
protected array $delayedUrlInfo Array of URL definitions: [route] - Route identifier (routeid or name) [$data] - Data for building route [extra] - Additional data to be added [options] - Options for building URL - noBaseUrl: skips adding the baseurl
protected array $delayedUrlKeys Array of the keys used by $delayedUrlInfo above
protected array $needBuilding Keeps track of which hashKeys in $delayedUrlInfo still need to be built.
protected array $builtUrlList Array of already built URLs.
protected array $builtUrlKeys Array of the keys used by $builtUrlList above Each element is a key:value pair of {String Hashkey}:{String Hashkey}, which are the keys for $builtUrlList.
protected bool $loadedUrlKeys Flag, whether finalBuildUrls() called route API's preloadRoutes() or not

Methods

instance()

Singleton instance getter

string
getPlaceholder(string $hash)

Returns the full URL placeholder based on the passed hash

string
register(int|string $route, array $data = array(), array $extra = array(), array $options = array())

Registers the information needed (route, data, etc) to create a URL and returns a placeholder so that template rendering can continue. The placeholders will be replaced in one go at the end of the rendering process.

String[]
finalBuildUrls(String[] $delayedUrlKeys)

Returns the URLs for the routes with the passed parameters

null
replacePlaceholders(string $content)

Replaces the placeholders with the actual URL in the passed content.

Details

at line 85
static vB5_Template_Url instance()

Singleton instance getter

Return Value

vB5_Template_Url

at line 103
protected string getPlaceholder(string $hash)

Returns the full URL placeholder based on the passed hash

Parameters

string $hash The hash

Return Value

string The full placeholder

at line 129
string register(int|string $route, array $data = array(), array $extra = array(), array $options = array())

Registers the information needed (route, data, etc) to create a URL and returns a placeholder so that template rendering can continue. The placeholders will be replaced in one go at the end of the rendering process.

Parameters

int|string $route The textual name of a route, along with optional modifiers. If modifiers are added they are separated with a pipe (|). OR the integer routeid of a route.
array $data Data needed to generate the URL. Normally the node array is passed. Fields potentially used are: 'title', 'startertitle', 'channeltitle', 'urlident','starterurlident', 'channelurlident', 'page', 'channelroute','starterroute' , 'contenttypeid', 'starter', 'channelid', 'nodeid', 'routeid', 'userid', 'authorname', 'contentpagenum'
array $extra Array of key:value pairs to be added to the URL as query parameters.
array $options Array of options to modify the generated URL. Currently supports: (this list may not be complete) 'anchor' => The anchor name for the #anchor hash at the end of the URL.

Return Value

string A string placeholder which is temporarily inserted in the rendered template.

at line 189
String[] finalBuildUrls(String[] $delayedUrlKeys)

Returns the URLs for the routes with the passed parameters

Parameters

String[] $delayedUrlKeys HashKeys that exist in the URL definitions list class var $this->delayedUrlInfo

Return Value

String[] hashKey => replacement URL

at line 329
null replacePlaceholders(string $content)

Replaces the placeholders with the actual URL in the passed content.

Builds any URLs that have not been built yet.

Parameters

string $content The content containing the placeholders (Passed by reference)

Return Value

null