本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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]();
示例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;
}
示例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());
}
示例7: __construct
public function __construct()
{
if (Route::getMethod() == null) {
echo "This is constuctor method";
}
}