Example #1
0
 /**
  * @param Route $route
  * @param array $params
  * @return string
  */
 protected function buildUrl(Route $route, array $params)
 {
     $targets = [];
     $replacements = [];
     foreach ($route->getVariableNames() as $key) {
         if (!isset($params[$key])) {
             throw new \InvalidArgumentException("Variable '{$key}' not found or null for route '{$route->getName()}'");
         }
         $targets[] = ":" . $key;
         $replacements[] = $params[$key];
     }
     return str_replace($targets, $replacements, $route->getUri());
 }