CapMousse\ReactRestify\Routing\Router::addGroup PHP Method

addGroup() public method

Create a new group of routes
public addGroup ( String $prefix, $callback ) : CapMousse\ReactRestify\Routing\Group
$prefix String prefix of thes routes
return CapMousse\ReactRestify\Routing\Group
    public function addGroup($prefix, $callback)
    {
        $group = new Routes($this, $prefix, $callback);
        return $group;
    }

Usage Example

Beispiel #1
0
 /**
  * Add a new group of routes
  * @param string   $prefix
  * @param Callable $callback
  *
  * return \CapMousse\ReactRestify\Routing\Group
  */
 public function group($prefix, $callback)
 {
     $group = $this->router->addGroup($this->prefix . '/' . $prefix, $callback);
     $group->onAny(function ($event, $arguments) {
         $this->emit($event, $arguments);
     });
 }