Pfw_XH
Public Member Functions | Static Public Member Functions | List of all members
Pfw\Url Class Reference

CMSimple_XH internal URLs as value objects. More...

Public Member Functions

 __toString ()
 Convenience wrapper for getRelative(). More...
 
 getRelative ()
 Return the "relative" URL string. More...
 
 getAbsolute ()
 Return the fully qualified absoulte URL string. More...
 
 with ($param, $value)
 Add or replace a query string parameter. More...
 
 without ($param)
 Remove a query string parameter. More...
 

Static Public Member Functions

static getCurrent ()
 Return the URL of the current request. More...
 

Detailed Description

CMSimple_XH internal URLs as value objects.

Url value objects are most useful to manipulate certain query string parameters of the requested URL, but can also be used to construct other URLs of the CMSimple_XH installation. At least for CMSimple_XH internal URLs they should be preferred over manual URL construction which is error prone and too concrete (consider clean URLs). Furthermore, the Url objects let you focus on removing and adding query string parameters as needed, instead of simply ignoring parameters of other plugins.

Typical usage example:

$url = Url::getCurrent()    // get current URL
    ->without('foo')        // remove the `foo` parameter
    ->with('bar', 'baz');   // add a `bar` parameter with value `baz`
$urlString = (string) $url;

Member Function Documentation

◆ __toString()

Pfw\Url::__toString ( )

Convenience wrapper for getRelative().

Returns
string

◆ getAbsolute()

Pfw\Url::getAbsolute ( )

Return the fully qualified absoulte URL string.

Returns
string

◆ getCurrent()

static Pfw\Url::getCurrent ( )
static

Return the URL of the current request.

Returns
self

◆ getRelative()

Pfw\Url::getRelative ( )

Return the "relative" URL string.

Actually, this method returns an absolute URL string, which is not fully qualified, though; it consists of path and query string only.

Returns
string

◆ with()

Pfw\Url::with (   $param,
  $value 
)

Add or replace a query string parameter.

If the $param query string parameter already exists, it is replaced with the new $value (which may be a string or an array). Otherwise the query parameter is added to the URL.

Parameters
string$param
mixed$value
Returns
self

◆ without()

Pfw\Url::without (   $param)

Remove a query string parameter.

The $param query string parameter is removed if it exists. Otherwise the method silently succeeds.

Parameters
string$param
Returns
self

The documentation for this class was generated from the following file: