Show:

Q_Uri Class

Module: Q

Represents an internal URI

Constructor

Q_Uri

()

Methods

__get

(
  • $field_name
)
String | Null

Returns the value of the specified URI field, or null if it is not present.

Parameters:

  • $field_name String

    The name of the field.

Returns:

String | Null:

Returns the value of the field, or null if not there.

__isset

(
  • $field_name
)

Returns whether the specified URI field is set

Parameters:

  • $field_name String

    The name of the field.

__set

(
  • $field_name
  • $value
)

Sets the value of the specified URI field

Parameters:

  • $field_name String

    The name of the field.

  • $value String | Array

    The value of the field

__toString

() String

Returns:

String:

cacheBaseUrl

(
  • [$base_url=null]
)
Array static

Set cache base url, relative to which this particular client may store cached versions of files.

Parameters:

  • [$base_url=null] Array optional

    If no arguments are passed, just returns the current cache base url.

Returns:

Array:

Returns the cache base url at the time the function was called.

decode

(
  • $tail
)
Array protected static

Parameters:

  • $tail String

    This can either be JSON, or something that looks like a=b c=d where a, b, c, d are urlencoded

Returns:

Array:

documentRoot

() String static

Returns:

String:

encode

(
  • $fields
)
String protected static

Parameters:

  • $fields Array

    An array of fields

Returns:

String:

A representation like a=b c=d where a, b, c, d are urlencoded

filenamefromUrl

(
  • $url
)
String static

Returns what the local filename of a local URL would typically be without any routing. If not found under docroot, also checks various aliases.

Parameters:

  • $url String

    The url to translate, whether local or an absolute url beginning with the base URL

Returns:

String:

The complete filename of the file or directory. It may not point to an actual file or directory, so use file_exists() or realpath()

fixUrl

(
  • $url
)
String static

Interpolates a URL and fixes it to have only one question mark and hash mark.

Parameters:

  • $url String

    The url to fix

Returns:

String:

The URL with all subsequent ? and # replaced by &

from

(
  • $source
  • [$route=null]
)
Q_Uri | False static

Constructs a URI object from something

Parameters:

  • $source String

    An absolute URL, or an array, or a URI in string form.

  • [$route=null] String optional

    The pattern of the route in the routes config. If not specified, then Qbix searches all the route patterns in order, until it finds one that fits. If you set this to false, then $source is treated as an absolute URL, regardless of its format.

Returns:

Q_Uri | False:

Returns false if no route patterns match. Otherwise, returns the URI.

fromArray

(
  • $source
)
Q_Uri protected static

Parameters:

  • $source Array

Returns:

fromString

(
  • $source
)
Q_Uri protected static

Parameters:

  • $source String

Returns:

fromUrl

(
  • $url
  • [$route=null]
)
Q_Uri protected static

Parameters:

  • $url String
  • [$route=null] String optional

Returns:

interpolateUrl

(
  • $url
  • [$additional=array()]
)
static

Interpolate some standard placeholders inside a url, such as {{AppName}} or {{PluginName}}

Parameters:

  • $url String
  • [$additional=array()] Array optional

    Any additional substitutions

Returns:

{strQ_Uri::interpolateUrlitutions applied

matchRoute

(
  • $pattern
  • $fields
  • [$controller=true]
)
String | False protected static

Parameters:

  • $pattern String
  • $fields Array
  • [$controller=true] String optional

Returns:

String | False:

Returns false if even one field doesn't match. Otherwise, returns the URL that would be routed to this uri.

matchSegments

(
  • $pattern
  • $segments
)
Array | False protected static

Parameters:

  • $pattern String

    The pattern (of the rule) to match

  • $segments String

    The segments extracted from the URL

Returns:

Array | False:

Returns false if one of the literal values doesn't match up, Otherwise, returns array of field => name pairs where fields were filled.

pluginBaseUrl

(
  • string
)
String static

Get the base url of a plugin

Parameters:

  • string Object

    $plugin The name of the plugin, with first letter uppercase.

Returns:

String:

Returns an absolute or relative URL

proxyDestination

(
  • $url
)
String static

If a proxy exists for this URL, returns the destination URL, otherwise returns the input URL

Parameters:

  • $url String

Returns:

String:

proxySource

(
  • $url
)
String static

If a proxy exists for this URL, returns the source URL, otherwise returns the input URL

Parameters:

  • $url String

Returns:

String:

route

() String

Get the route that was used to obtain this URI from a URL

Returns:

String:

suffix

(
  • [$suffix=null]
)
Array static

Set a suffix for all URLs that will be generated with this class.

Parameters:

  • [$suffix=null] Array | String optional

    If no arguments are passed, just returns the current suffix. Pass an array here. For each entry, the key is tested and if it begins the URL, then the value is appended. Suffixes are applied when URLs are generated. You can also pass a string here, in which case the array('' => $suffix) is used.

Returns:

Array:

Returns the suffix at the time the function was called.

toArray

() Array

Returns:

Array:

toUrl

(
  • [$route=null]
  • [$controller=true]
)
String

Maps this URI into an external URL.

Parameters:

  • [$route=null] String optional

    If you name the route to use for unrouting, it will be used as much as possible. Otherwise, Qbix will go through the routes one by one in order, until it finds one that can route a URL to the full URI contained in this object.

  • [$controller=true] String optional

    You can supply a different controller name, like 'tool.php'

Returns:

String:

If a $route is specified, the router uses this route and replaces as many variables as it can to match the $internal_destination. If not, the router tries to find a route and use it to make an external URL that maps to the internal destination exactly, but if none of the routes can do this, it returns an empty string. You may want to use Q_Uri::proxySource() on the returned url to get the proxy url corresponding to it.

url

(
  • $source
  • [$route=null]
  • [$noProxy=false]
  • [$controller=true]
)
String static

Takes some input and returns the corresponding URL

Parameters:

  • $source String | Boolean | Array | Q_Uri

    This can be a Q_Uri, an array or string representing a uri, an absolute url, or "true". If you pass "true", then the Q_Request::baseUrl(true) is used as input.

  • [$route=null] String | Null optional

    If you know which route pattern to use, then specify it here. Otherwise, leave it null.

  • [$noProxy=false] Boolean optional

    If set to true, Q_Uri::proxySource($url) is not called before returning the result.

  • [$controller=true] String optional

    The controller to pass to Q_Request::baseUrl($controller) when forming the URL.

Returns:

String:

Properties

$anchorstring

String protected

$cacheBaseUrl

String public

$fields

Array protected

$querystring

String protected

$route

String protected

$suffix

Array protected

$url

Array public

$urls

String public

$variablePrefixes

Array public

$variablePrefixes

Array public

Events

Q/Uri/fromUrl

Before

Hook for custom logic modifying routing from URLs to internal URIs

Event Payload:

  • url String

Q/Uri/pluginUrl

Before

Hook for custom logic modifying the urls for a plugin

Event Payload:

  • plugin String

Q/Uri/toUrl

Before

Event Payload:

  • uri Q_Uri

    This is the uri being turned into a URL

  • route String | Null

    The route that is going to be used (from config)

  • controller String | Null

    The controller that is being used for the baseUrl

  • url String | Null

    The computed url, that will be returned. You can modify it.