Url
in package
URL Class
The URL class is used for generating URLs and other related things. Relies on there being a get_http_var() function.
This is probably how you'll use it most:
$URL = new \MySociety\TheyWorkForYou\Url("YOURPAGENAME");
print $URL->generate();
In the metadata you should set a session_vars variable, an array. The default page session_vars may be just array("debug"). These can then be overridden on a per-page basis. Session vars are GET/POST vars that will be passed by default to that page. ie, if "foo=bar" is in the current URL and you generate a URL to a page that has "foo" as a session_var, "foo=bar" will be automatically added to the generated URL. You can modify the session vars that will be included in the URL generated using the functions below.
Tags
Table of Contents
Methods
- __construct() : mixed
- generate() : mixed
- Generate URL
- insert() : mixed
- Insert Session Key/Value Pairs
- remove() : mixed
- Remove Session Key/Value Pair
- reset() : mixed
- Reset Session Variables
- restore() : mixed
- Restore Session Variables
- update() : mixed
- Update Values
Methods
__construct()
public
__construct(mixed $pagename) : mixed
Parameters
- $pagename : mixed
generate()
Generate URL
public
generate([mixed $encode = "html" ][, mixed $overrideVars = array() ]) : mixed
Generate a URL to the page specified with session vars.
Parameters
- $encode : mixed = "html"
- $overrideVars : mixed = array()
insert()
Insert Session Key/Value Pairs
public
insert(array<string|int, mixed> $arr) : mixed
Parameters
- $arr : array<string|int, mixed>
-
An associative array of key/value pairs
remove()
Remove Session Key/Value Pair
public
remove(array<string|int, mixed> $arr) : mixed
Parameters
- $arr : array<string|int, mixed>
-
A list array of key names to remove
reset()
Reset Session Variables
public
reset() : mixed
Removes all session variables.
restore()
Restore Session Variables
public
restore() : mixed
Restores the session variables to their state when the object was instantiated.
update()
Update Values
public
update(array<string|int, mixed> $arr) : mixed
Any keys in session_vars that are also in $arr will have their values overwritten by those in $arr. Other session_var key/vals are not affected.
Parameters
- $arr : array<string|int, mixed>
-
An associative array of key/value pairs.