コード例 #1
0
 /**
  * Find matching route in XML route configuration and return modified request string 
  *
  * @param string $request
  * @return mixed
  * @deprecated
  */
 private final function xml_route($request)
 {
     $xml_routes = new XML\Parser();
     $xml_routes->load_from_file($this->routes_file);
     $routes = $xml_routes->getElementsByAttributeValue('method', Request::get_request_type());
     $found_route = null;
     foreach ($routes as $item) {
         if ($item->nodeType == XML_ELEMENT_NODE) {
             foreach ($item->childNodes as $attr) {
                 if ($attr->nodeType == XML_ELEMENT_NODE) {
                     if ($attr->tagName == "request") {
                         if ($item->getAttribute('method') == $_SERVER['REQUEST_METHOD']) {
                             $match_route = $item->cloneNode(true);
                             $controller = $match_route->getElementsByTagName('controller')->item(0)->nodeValue;
                             $action = $match_route->getElementsByTagName('action')->item(0)->nodeValue;
                             $match = str_ireplace('/', '\\/', $match_route->getElementsByTagName('request')->item(0)->nodeValue);
                             $match = '/^' . $match . '$/';
                             $replace = "/{$controller}/{$action}";
                             if ($match_route->getAttribute('args') == true) {
                                 $args_num = $match_route->getAttribute('argsnum');
                                 $number_args = !empty($args_num) ? $args_num : preg_match_all("/(\\(.*?\\))/", $match);
                                 for ($i = 1; $i <= $number_args; $i++) {
                                     $replace .= "/\$" . $i;
                                 }
                             }
                             if (preg_match($match, $request)) {
                                 $request = preg_replace($match, $replace, $request);
                                 $found_route = $item->cloneNode(true);
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         if ($found_route !== null) {
             break;
         }
     }
     return $request;
 }
コード例 #2
0
ファイル: Writer.php プロジェクト: youmy001/apine-framework
 /**
  * Writer constructor.
  */
 public function __construct()
 {
     parent::__construct();
 }