Пример #1
0
 /**
  * @param string $name
  * @param array  $params
  * @return string
  */
 public function assemble($name, $params = [])
 {
     $route = $this->get($name);
     $this->buildNameCache();
     $path = $route->getPath();
     $routeParts = $this->routeParser->parse($path);
     $useOptional = false;
     // $routeParts contains at most two entries
     // the first is the route parsed without the optional segment
     // the second is the route with the optional segment
     // this determines which part we should use to assemble the array
     if (isset($routeParts[1])) {
         $useOptional = true;
         foreach ($routeParts[1] as $part) {
             if (is_string($part)) {
                 continue;
             }
             if (isset($params[$part[0]])) {
                 continue;
             }
             $useOptional = false;
             break;
         }
     }
     return $this->assembleFromParts($name, $params, $useOptional ? $routeParts[1] : $routeParts[0]);
 }
Пример #2
0
 public function route($route)
 {
     $parser = new Std();
     $detail = $parser->parse($route);
     $routes = [];
     $observable = new ReplaySubject();
     foreach ($detail as $routeData) {
         $b = $this->buildRegexForRoute($routeData);
         //print_r($b);
         $regex = '(' . $b[0] . ')';
         $routeMap = $b[1];
         $routes[] = compact('regex', 'routeMap');
     }
     $this->routing->attach($observable, $routes);
     return $observable->asObservable();
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function parse($route)
 {
     return parent::parse(static::replaceRegexAliases($route));
 }