本文整理汇总了PHP中Route::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::getName方法的具体用法?PHP Route::getName怎么用?PHP Route::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Route
的用法示例。
在下文中一共展示了Route::getName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* constructor
*
* @param \Naquadria\Components\Routing\Route $route
* @param array $routeData
* @param array $replacer
*/
public function __construct(Route $route, array $routeData, array $replacer)
{
$this->name = $route->getName();
$this->abstraction = $route->getAbstraction();
$this->data = $routeData;
$this->replacer = $replacer;
$this->route = $route;
}
示例2: __construct
/**
* @param Route $route The unparsed route whose properties we are copying
*/
public function __construct(Route $route)
{
parent::__construct($route->getMethods(), $route->getRawPath(), $route->getController());
$this->setName($route->getName());
$this->setRawHost($route->getRawHost());
$this->addMiddleware($route->getMiddleware());
$this->setSecure($route->isSecure());
$this->setVarRegexes($route->varRegexes);
}
示例3: go
public function go($path)
{
$asset = \Route::getName();
$inputfile = HOME_DIR . '/templates/' . \App::get('template') . '/' . $asset . '/' . $path;
$file = new \File($inputfile);
if ($file->exists()) {
$this->response->setMIME($file->detectMime())->out($file->get());
}
}
示例4: __construct
/**
* RouteLink constructor.
*
* @param $params
* @param \HBM\DatagridBundle\Model\Route $route
*/
public function __construct($params, Route $route)
{
parent::__construct();
$this->params = $params;
if ($route !== NULL) {
$this->name = $route->getName();
$this->defaults = $route->getDefaults();
}
}
示例5: map
public function map($routeUrl, $target = '', array $args = array())
{
$route = new Route();
$route->setUrl($this->basePath . $routeUrl);
$route->setTarget($target);
if (isset($args['methods'])) {
$methods = explode(',', $args['methods']);
$route->setMethods($methods);
}
if (isset($args['filters'])) {
$route->setFilters($args['filters']);
}
if (isset($args['name'])) {
$route->setName($args['name']);
if (!isset($this->namedRoutes[$route->getName()])) {
$this->namedRoutes[$route->getName()] = $route;
}
}
$this->routes[] = $route;
}
示例6: compileRoute
/**
* {@inheritDoc}
*
* @throws RuntimeException
*/
protected function compileRoute(Route $route)
{
$parameters = $this->processPathParameters($route->getPath());
$regexp = $route->getPath();
foreach ($parameters as $parameter) {
if (substr_count($route->getPath(), '{' . $parameter . '}') > 1) {
throw new \RuntimeException(sprintf('Route name "%s" cannot reference variable "%s" more than once.', $route->getName(), $parameter));
}
$regexp = str_replace('{' . $parameter . '}', '(?<' . $parameter . '>[A-z0-9_-]+)', $regexp);
}
$regexp = "#^{$regexp}\$#";
return ['parameters' => $parameters, 'regexp' => $regexp];
}
示例7: processRoute
/**
* @param array $routeConfig
* @param Route|null $parentRoute
*
* @return Route
*/
private function processRoute(array $routeConfig, Route $parentRoute = null)
{
$name = $routeConfig['name'];
$url = isset($routeConfig['options']['route']) ? $routeConfig['options']['route'] : '';
$controller = isset($routeConfig['options']['defaults']['controller']) ? $routeConfig['options']['defaults']['controller'] : null;
$action = isset($routeConfig['options']['defaults']['action']) ? $routeConfig['options']['defaults']['action'] : null;
if (null !== $parentRoute) {
$name = $parentRoute->getName() . '/' . $name;
$url = $parentRoute->getUrl() . $url;
if (null === $controller) {
$controller = $parentRoute->getController();
}
}
if (null === $action) {
$action = 'index';
}
$action .= 'Action';
return new Route($name, $url, $controller, $action);
}
示例8: 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;
}
示例9: setRoute
public function setRoute(Route $route)
{
$this->add($route->getName(), $route->getMethod(), $route->getPath(), $route->getHandler());
}
示例10: addRoute
/**
* @param Route $route
*/
public function addRoute(Route $route)
{
$this->routes[$route->getName()] = $route;
}
示例11: testGetName
public function testGetName()
{
$route = new Route("herp", "derp", "target");
self::assertEquals("herp", $route->getName());
}
示例12: addRoute
/**
* Добавление роута в список роутов
* @param Route $route
*/
protected static function addRoute(Route $route)
{
static::$_routes[$route->getName()] = $route;
}
示例13: buildUrl
/**
* @param Route $route
* @param array $params
* @return string
*/
protected function buildUrl(Route $route, array $params)
{
$targets = [];
$replacements = [];
foreach ($route->getVariableNames() as $key) {
if (!isset($params[$key])) {
throw new \InvalidArgumentException("Variable '{$key}' not found or null for route '{$route->getName()}'");
}
$targets[] = ":" . $key;
$replacements[] = $params[$key];
}
return str_replace($targets, $replacements, $route->getUri());
}