pclib  2.9.5
Lightweight PHP framework
Public Member Functions | Data Fields
Router Class Reference

Translates URL to instance of Action class. More...

Inheritance diagram for Router:
BaseObject

Public Member Functions

 getAction ()
 Create Action from current request. More...
 
 addRedirect ($old, $new, $code=302)
 Set route to be redirected. More...
 
 followRedirects ()
 Redirect old route to new route, if it was added by addRedirect().
 
 redirect ($route, $code=null)
 Redirect to $route or url.
 
 createUrl ($s)
 Transform internal action (for example 'products/edit/id:1') to URL. More...
 
- Public Member Functions inherited from BaseObject
 loadDefaults ($className=null)
 Load default parameters of class $className into object instance.
 
 setProperties (array $defaults)
 Set public properties of object from the array. More...
 
 toArray ()
 Convert object to array. More...
 

Data Fields

 $friendlyUrl = false
 Create friendly URL?
 
 $action
 var Action Current Action
 
- Data Fields inherited from BaseObject
 $serviceLocator
 var function() Return service object when requested with service().
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseObject
static defaults ()
 Set or retireve default parameters of the object. More...
 
- Protected Member Functions inherited from BaseObject
 service ($service, $default=null)
 Try acquire $service and load it into property $this->$service. More...
 

Detailed Description

Translates URL to instance of Action class.

Action contains class and method name (with parameters) which will be called.

Member Function Documentation

◆ addRedirect()

addRedirect (   $old,
  $new,
  $code = 302 
)

Set route to be redirected.

Parameters
string$oldOld route
string$newNew route
string$codeHTTP status code: 302 temporary | 301 permanent

◆ createUrl()

createUrl (   $s)

Transform internal action (for example 'products/edit/id:1') to URL.

Parameters
string | Action$s
Returns
string $url

◆ getAction()

getAction ( )

Create Action from current request.

Override for your own URL format.

Returns
Action $action

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