当前位置: 首页>>代码示例>>PHP>>正文


PHP Route::getMethod方法代码示例

本文整理汇总了PHP中Route::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::getMethod方法的具体用法?PHP Route::getMethod怎么用?PHP Route::getMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Route的用法示例。


在下文中一共展示了Route::getMethod方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addRoute

 public static function addRoute(Route $route)
 {
     static::$routes[] = $route;
     $method = $route->getMethod();
     $addr = $route->getAddr();
     $argsSize = $route->getArgsSize();
     $route->addToTree(static::$routesTree);
     return $route;
 }
开发者ID:smoren,项目名称:mushroom-framework,代码行数:9,代码来源:Router.php

示例2: add

 public function add(Route $route)
 {
     $path = $route->getParsed()->getPathPattern();
     $method = $route->getMethod();
     if (!isset($this->pathMethodMap[$path])) {
         $this->pathMethodMap[$path] = [];
     } else {
         if (in_array($method, $this->pathMethodMap[$path])) {
             throw new \InvalidArgumentException("Method {$method} is already defined for {$path}");
         }
     }
     $name = $route->getName();
     if ($name !== null) {
         if (isset($this->routeNames[$name])) {
             throw new \InvalidArgumentException("Route {$name} is already defined");
         }
         $this->routeNames[$name] = $route;
     }
     $this->pathMethodMap[$path][] = $method;
     $this->routes[] = $route;
 }
开发者ID:bugadani,项目名称:routy,代码行数:21,代码来源:RouteContainer.php

示例3: addVariableRoute

 /**
  *
  */
 private function addVariableRoute($routeData, Route $route)
 {
     list($regex, $arguments) = $this->buildRegexForRoute($routeData);
     foreach ($route->getMethod() as $method) {
         if (isset($this->dynamicRoutes[$method][$regex])) {
             throw new Exception("Cannot register two routes matching \"{$regex}\" for method \"{$method}\"");
         }
         $route->regex = $regex;
         $route->arguments = $arguments;
         $this->dynamicRoutes[$method][$regex] = $route;
     }
 }
开发者ID:wispira,项目名称:framework,代码行数:15,代码来源:Router.php

示例4:

<?php

//This Application Development by ITGET Business Solution
//Powered by ITGET PHP Framework Version 1.0.alpha.1
//www.itget.net info@itget.net
include 'url_rewrite.php';
include 'auto_load.php';
$className = Route::getClass();
$obj = new $className();
if (($methodName = Route::getMethod()) !== null) {
    $obj->{$methodName}();
}
//$home->$_URL[1]();
开发者ID:sodemacom,项目名称:ITG,代码行数:13,代码来源:starter.php

示例5: matchRoute

 /**
  * Checks if the URL matches the transmitted rule.
  *
  * @param Route $route Object
  *
  * @return bool
  */
 protected function matchRoute($route)
 {
     $params = array();
     $key_params = array_keys($route->getParams());
     $value_params = $route->getParams();
     foreach ($key_params as $key) {
         $params['<' . $key . '>'] = $value_params[$key];
     }
     $url = $this->basePath . $route->getPath();
     // Replaces the corresponding marks on regular expressions
     $url = str_replace(array_keys($params), $params, $url);
     // If no tag in the $ params array allows for any character
     $url = preg_replace('/<\\w+>/', '.*', $url);
     // checks pattern matching
     preg_match("#^{$url}\$#", $this->url, $results);
     if ($results) {
         $this->class = $route->getClass();
         $this->method = $route->getMethod();
         return true;
     }
     return false;
 }
开发者ID:pawelbienko,项目名称:rest-without-framework,代码行数:29,代码来源:Router.php

示例6: testMethod

 public function testMethod()
 {
     // all
     $route = new Route("/");
     $this->assertEquals("", $route->getMethod());
     $this->assertSame(null, $route->getMethod());
     // GET
     $route->setMethod("GET");
     $this->assertEquals("GET", $route->getMethod());
     // lowercase
     $route->setMethod("post");
     $this->assertEquals("POST", $route->getMethod());
     // all
     $route->setMethod(null);
     $this->assertEquals("", $route->getMethod());
     $this->assertSame(null, $route->getMethod());
     // several
     $route->setMethod("GET|POST|PUT");
     $this->assertEquals("GET|POST|PUT", $route->getMethod());
     // all
     $route->setMethod("");
     $this->assertEquals("", $route->getMethod());
     $this->assertSame(null, $route->getMethod());
 }
开发者ID:sugiphp,项目名称:routing,代码行数:24,代码来源:RouteTest.php

示例7: __construct

 public function __construct()
 {
     if (Route::getMethod() == null) {
         echo "This is constuctor method";
     }
 }
开发者ID:sodemacom,项目名称:ITG,代码行数:6,代码来源:home.controller.php


注:本文中的Route::getMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。