name() public method

Sets the route name if a non-empty string is provided, and then returns the Route instance to allow a fluent interface. Otherwise, returns the route name.
public name ( null | string $name = null ) : Route | string
$name null | string
return Route | string
示例#1
0
文件: App.php 项目: phly/phlyty
 /**
  * Register a named route
  *
  * @param  Route $route
  * @throws Exception\DuplicateRouteException if route with the same name already registered
  */
 protected function registerNamedRoute(Route $route)
 {
     $name = $route->name();
     if (!$name) {
         return;
     }
     if (isset($this->namedRoutes[$name])) {
         if ($route === $this->namedRoutes[$name]) {
             return;
         }
         throw new Exception\DuplicateRouteException(sprintf('Duplicate attempt to register route by name "%s" detected', $name));
     }
     $this->namedRoutes[$name] = $route;
 }