コード例 #1
0
ファイル: Builder.php プロジェクト: dez-php/dez-url
 /**
  * @param Route $route
  * @param array $parameters
  * @return $this
  */
 protected function makeLink(Route $route, array $parameters = [])
 {
     $link = $route->getPseudoPattern();
     if (count($parameters) > 0) {
         $replacements = array_values($parameters);
         $search = array_map(function ($name) {
             return ":{$name}";
         }, array_keys($parameters));
         $link = str_replace($search, $replacements, $link);
     }
     $this->setLink($link);
     $this->setFounded(true);
     return $this;
 }
コード例 #2
0
ファイル: Router.php プロジェクト: dez-php/dez-router
 /**
  * @param string $pattern
  * @param null $matches
  * @param null $methods
  * @return Route
  * @throws Exception
  * @throws \Dez\EventDispatcher\Exception
  */
 public function add($pattern = '', $matches = null, $methods = null)
 {
     $this->getEventDispatcher()->dispatch(EventRouter::BEFORE_ROUTE_ADD, new EventRouter($this));
     $route = new Route($pattern, $matches, $methods);
     $route->setDi($this->getDi());
     $this->routes[] = $route;
     $this->getEventDispatcher()->dispatch(EventRouter::AFTER_ROUTE_ADD, new EventRouter($this));
     return $route;
 }