getName() public method

public getName ( ) : string
return string
Example #1
0
 /**
  * @param Route $route
  * @return self
  */
 public function addRoute(Route $route)
 {
     $name = $route->getName();
     if (isset($this->routes[$name])) {
         throw new DomainException(sprintf('Failed adding route by name %s; a route by that name has already been registered', $name));
     }
     $this->routes[$name] = $route;
     ksort($this->routes, defined('SORT_NATURAL') ? constant('SORT_NATURAL') : SORT_STRING);
     return $this;
 }
Example #2
0
 public function dispatch(Route $route, ConsoleAdapter $console)
 {
     $name = $route->getName();
     if (!isset($this->commandMap[$name])) {
         $console->writeLine('');
         $console->writeLine(sprintf('Unhandled command "%s" invoked', $name), Color::WHITE, Color::RED);
         $console->writeLine('');
         $console->writeLine('The command does not have a registered handler.');
         return 1;
     }
     $callable = $this->commandMap[$name];
     if (!is_callable($callable) && is_string($callable)) {
         $callable = new $callable();
         if (!is_callable($callable)) {
             throw new RuntimeException(sprintf('Invalid command class specified for "%s"; class must be invokable', $name));
         }
         $this->commandMap[$name] = $callable;
     }
     $return = $this->container->call($callable, [$route, $console, $this->container]);
     return (int) $return;
 }
Example #3
0
 /**
  * Dispatches route
  *
  * @param Route $route
  * @param ConsoleAdapter $console
  * @throws RuntimeException
  * @return number
  */
 public function dispatch(Route $route, ConsoleAdapter $console)
 {
     $name = $route->getName();
     if (!isset($this->commandMap[$name])) {
         $console->writeLine('');
         $console->writeLine(sprintf('Unhandled command "%s" invoked', $name), Color::WHITE, Color::RED);
         $console->writeLine('');
         $console->writeLine('The command does not have a registered handler.');
         return 1;
     }
     $callable = $this->commandMap[$name];
     if (!is_callable($callable) && is_string($callable)) {
         $callable = new $callable();
         if (!is_callable($callable)) {
             throw new RuntimeException(sprintf('Invalid command class specified for "%s"; class must be invokable', $name));
         }
         $this->commandMap[$name] = $callable;
     }
     if ($this->getServiceLocator() !== null && $callable instanceof ServiceLocatorAwareInterface && $callable->getServiceLocator() === null) {
         $callable->setServiceLocator($this->getServiceLocator());
     }
     $return = call_user_func($callable, $route, $console);
     return (int) $return;
 }
Example #4
0
 public function testConstructorExpectsNameAndRoute()
 {
     $route = new Route('foo', 'foo bar');
     $this->assertEquals('foo', $route->getName());
     $this->assertEquals('foo bar', $route->getRoute());
 }