.

InstanceReferenceRoute Class Reference

A route that contains a reference to an instance. More...

Inheritance diagram for InstanceReferenceRoute:
ParameterizedRoute RouteBase IRoute IDispatcher IUrlBuilder

List of all members.

Protected Member Functions

  build_unknown_type_regexp ($type, $params)
  Can be overloaded to support further types.
  build_url_path ($params)
  Build the URL (except base part).
  replace_path_variable ($path, $key, $value)
  Replace a variable in the path with a given value.

Detailed Description

A route that contains a reference to an instance.

The route adds the type "inst" to the parameterized route. However, it must be the last element and requires to declare it using "%".

Example: https://voting/vote/{instance:inst}%

Definition at line 10 of file instancereferenceroute.cls.php.


Member Function Documentation

InstanceReferenceRoute::build_unknown_type_regexp ( type,
params  
) [protected]

Can be overloaded to support further types.

Parameters:
string  $type The type of an expression
string  $params Optional params
Returns:
string A regular expression

Reimplemented from ParameterizedRoute.

Definition at line 18 of file instancereferenceroute.cls.php.

00018                                                                      {
00019                 $ret = '';
00020                 if ($type == 'inst') {
00021                         $ret = '.*?'; // Any string
00022                 }
00023                 else {
00024                         $ret = parent::build_unknown_type_regexp($type, $params);
00025                 }
00026                 return $ret;
00027         }
InstanceReferenceRoute::build_url_path ( params  )  [protected]

Build the URL (except base part).

Parameters:
mixed  $params Further parameters to use to build URL
Returns:
string

Reimplemented from ParameterizedRoute.

Definition at line 35 of file instancereferenceroute.cls.php.

00035                                                    {
00036                 $arr = $params;
00037                 if ($params instanceof IDataObject) {
00038                         // Try to find the inst type
00039                         $regexp = '|\{([^:]*):inst\}|';
00040                         $matches = array();
00041                         $result = preg_match($regexp, $this->path, $matches);
00042                         if ($result) {
00043                                 $var_name = $matches[1];
00044                                 $arr = array($var_name => $params); 
00045                         }                       
00046                 }
00047                 return parent::build_url_path($arr);
00048         }
InstanceReferenceRoute::replace_path_variable ( path,
key,
value  
) [protected]

Replace a variable in the path with a given value.

Parameters:
string  $path
string  $key
mixed  $value
Returns:
string

Reimplemented from ParameterizedRoute.

Definition at line 58 of file instancereferenceroute.cls.php.

00058                                                                       {
00059                 if ($value instanceof IDataObject) {
00060                         return parent::replace_path_variable($path, $key, InstanceReferenceSerializier::instance_to_string($value));
00061                 }
00062                 return parent::replace_path_variable($path, $key, $value);
00063         }

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