Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function add(RouterInterface $router, Route $route)
 {
     //resolves actions with http methods
     $actions = $route->getParam('actions');
     if (empty($actions)) {
         $actions = array('/' => array('index' => Method::GET));
     }
     //add routes with http method
     //for each action new route is adding with specified HTTP Method.
     foreach ($actions as $actionRoute => $actionMethods) {
         if ($actionRoute == '/') {
             $actionRoute = '';
         }
         foreach ($actionMethods as $action => $method) {
             $paths = $route->getPaths();
             $paths['action'] = $action;
             $newRoute = $router->add($route->getRoute() . $actionRoute, $paths)->via($method);
             $newRoute->setName($route->getName() . $actionRoute . '/' . $action);
             $newRoute->setHostName($route->getParam('hostname'));
         }
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function add(RouterInterface $router, Route $route)
 {
     $router->add($route->getRoute(), $route->getPaths())->setName($route->getName())->setHostName($route->getParam('hostname'));
 }