00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010 class InstanceReferenceRoute extends ParameterizedRoute {
00011
00012
00013
00014
00015
00016
00017
00018 protected function build_unknown_type_regexp($type, $params) {
00019 $ret = '';
00020 if ($type == 'inst') {
00021 $ret = '.*?';
00022 }
00023 else {
00024 $ret = parent::build_unknown_type_regexp($type, $params);
00025 }
00026 return $ret;
00027 }
00028
00029
00030
00031
00032
00033
00034
00035 protected function build_url_path($params) {
00036 $arr = $params;
00037 if ($params instanceof IDataObject) {
00038
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 }
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 protected function replace_path_variable($path, $key, $value) {
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 }
00064 }