Exemple #1
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     $remainder = $result->get_remainder();
     // ensure remainder starts and ends with a slash:
     $starts_with_slash = $remainder[0] == '/';
     if (!$starts_with_slash) {
         $remainder = '/' . $remainder;
     }
     if (substr($remainder, -1) != '/') {
         $remainder .= '/';
     }
     // try to get the folder that corresponds to the unresolved path remainder:
     $folder_settings = $this->get_folder_settings($request->get_site_id(), $remainder);
     if ($folder_settings) {
         $result->set_resource_parameter('folder_id', $folder_settings['Subdivision_ID']);
         // do not remove trailing slash, but remove the slash added above
         $chars_to_remove = strlen($folder_settings['Hidden_URL']) - ($starts_with_slash ? 1 : 2);
         $result->truncate_remainder($chars_to_remove);
         return true;
     } else {
         return false;
     }
 }
Exemple #2
0
 /**
  * @param nc_routing_request $request
  * @return nc_routing_result|false
  */
 public function resolve(nc_routing_request $request)
 {
     $result_class = "nc_routing_result_" . $this->get('resource_type');
     /** @var nc_routing_result $result */
     $result = new $result_class($request->get_path(), $this->get('resource_parameters'), $this->get('query_variables'));
     if (!$this->get_pattern()->match($request, $result) || !$result->is_resolved()) {
         return false;
     }
     return $result;
 }