protected substituteAttributesInRoute ( $attributes, string $route ) : string | ||
$attributes | array Array of attributes | |
$route | string | string route to substitute |
return | string | route with attributes changed |
protected function substituteAttributesInRoute($attributes, $route)
{
foreach ($attributes as $key => $value) {
$route = str_replace("{" . $key . "}", $value, $route);
$route = str_replace("{" . $key . "?}", $value, $route);
}
// delete empty optional arguments that are not in the $attributes array
$route = preg_replace('/\\/{[^)]+\\?}/', '', $route);
return $route;
}