Q_Uri Class
Represents an internal URI
Constructor
Q_Uri
()
Item Index
Methods
- __get
- __isset
- __set
- __toString
- cacheBaseUrl static
- decode static
- documentRoot static
- encode static
- filenamefromUrl static
- fixUrl static
- from static
- fromArray static
- fromString static
- fromUrl static
- interpolateUrl static
- matchRoute static
- matchSegments static
- pluginBaseUrl static
- proxyDestination static
- proxySource static
- route
- suffix static
- toArray
- toUrl
- url static
Properties
Methods
__get
-
$field_name
Returns the value of the specified URI field, or null if it is not present.
Parameters:
-
$field_name
StringThe name of the field.
Returns:
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
StringThe name of the field.
__set
-
$field_name
-
$value
Sets the value of the specified URI field
Parameters:
-
$field_name
StringThe name of the field.
-
$value
String | ArrayThe value of the field
__toString
()
String
Returns:
cacheBaseUrl
-
[$base_url=null]
Set cache base url, relative to which this particular client may store cached versions of files.
Parameters:
-
[$base_url=null]
Array optionalIf no arguments are passed, just returns the current cache base url.
Returns:
Returns the cache base url at the time the function was called.
decode
-
$tail
Parameters:
-
$tail
StringThis can either be JSON, or something that looks like a=b c=d where a, b, c, d are urlencoded
Returns:
documentRoot
()
String
static
Returns:
encode
-
$fields
Parameters:
-
$fields
ArrayAn array of fields
Returns:
A representation like a=b c=d where a, b, c, d are urlencoded
filenamefromUrl
-
$url
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
StringThe url to translate, whether local or an absolute url beginning with the base URL
Returns:
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
Interpolates a URL and fixes it to have only one question mark and hash mark.
Parameters:
-
$url
StringThe url to fix
Returns:
The URL with all subsequent ? and # replaced by &
from
-
$source
-
[$route=null]
Constructs a URI object from something
Parameters:
-
$source
StringAn absolute URL, or an array, or a URI in string form.
-
[$route=null]
String optionalThe 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:
Returns false if no route patterns match. Otherwise, returns the URI.
fromUrl
-
$url
-
[$route=null]
Parameters:
-
$url
String -
[$route=null]
String optional
Returns:
interpolateUrl
-
$url
-
[$additional=array()]
Interpolate some standard placeholders inside a url, such as {{AppName}} or {{PluginName}}
Parameters:
-
$url
String -
[$additional=array()]
Array optionalAny additional substitutions
Returns:
{strQ_Uri::interpolateUrlitutions applied
matchRoute
-
$pattern
-
$fields
-
[$controller=true]
Parameters:
-
$pattern
String -
$fields
Array -
[$controller=true]
String optional
Returns:
Returns false if even one field doesn't match. Otherwise, returns the URL that would be routed to this uri.
matchSegments
-
$pattern
-
$segments
Parameters:
-
$pattern
StringThe pattern (of the rule) to match
-
$segments
StringThe segments extracted from the URL
Returns:
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
Get the base url of a plugin
Parameters:
-
string
Object$plugin The name of the plugin, with first letter uppercase.
Returns:
Returns an absolute or relative URL
proxyDestination
-
$url
If a proxy exists for this URL, returns the destination URL, otherwise returns the input URL
Parameters:
-
$url
String
Returns:
proxySource
-
$url
If a proxy exists for this URL, returns the source URL, otherwise returns the input URL
Parameters:
-
$url
String
Returns:
route
()
String
Get the route that was used to obtain this URI from a URL
Returns:
suffix
-
[$suffix=null]
Set a suffix for all URLs that will be generated with this class.
Parameters:
-
[$suffix=null]
Array | String optionalIf 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:
Returns the suffix at the time the function was called.
toArray
()
Array
Returns:
toUrl
-
[$route=null]
-
[$controller=true]
Maps this URI into an external URL.
Parameters:
-
[$route=null]
String optionalIf 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 optionalYou can supply a different controller name, like 'tool.php'
Returns:
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]
Takes some input and returns the corresponding URL
Parameters:
-
$source
String | Boolean | Array | Q_UriThis 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 optionalIf you know which route pattern to use, then specify it here. Otherwise, leave it null.
-
[$noProxy=false]
Boolean optionalIf set to true, Q_Uri::proxySource($url) is not called before returning the result.
-
[$controller=true]
String optionalThe controller to pass to
Q_Request::baseUrl($controller)
when forming the URL.
Returns:
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_UriThis is the uri being turned into a URL
-
route
String | NullThe route that is going to be used (from config)
-
controller
String | NullThe controller that is being used for the baseUrl
-
url
String | NullThe computed url, that will be returned. You can modify it.