- Adjusted route name on exception
This commit is contained in:
parent
3bcd5c9780
commit
710ecad98d
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Picea\Extension;
|
||||
|
||||
use Notes\Route\Attribute\Object\Route;
|
||||
use Picea\Compiler\Context;
|
||||
|
||||
class UrlExtension implements Extension, FunctionExtension {
|
||||
@ -115,7 +116,7 @@ PATTERN;
|
||||
public function buildRouteUrl(string $name, array $parameters = [], bool $appendVersion = false) : string
|
||||
{
|
||||
if ( false !== ( $route = $this->routes[$name] ?? false ) ) {
|
||||
return $this->buildUrl($this->prepareRoute($route['route'], $parameters), $parameters, $appendVersion);
|
||||
return $this->buildUrl($this->prepareRoute($route, $parameters), $parameters, $appendVersion);
|
||||
}
|
||||
|
||||
$routeList = json_encode($this->routes, \JSON_PRETTY_PRINT);
|
||||
@ -221,8 +222,10 @@ PATTERN;
|
||||
|| ( "off" !== ( strtolower($_SERVER['HTTPS'] ?? $_SERVER['HTTP_X_FORWARDED_SSL'] ?? $_SERVER['X-Forwarded-Ssl'] ?? "off")) );
|
||||
}
|
||||
|
||||
protected function prepareRoute(string $route, array &$arguments)
|
||||
protected function prepareRoute(array $routeParam, array &$arguments)
|
||||
{
|
||||
$route = $routeParam['route'];
|
||||
|
||||
if ( preg_match_all('~{(.*?)}~si', $route, $matches, PREG_SET_ORDER) ) {
|
||||
$search = [];
|
||||
|
||||
@ -249,8 +252,13 @@ PATTERN;
|
||||
if ($default ?? false) {
|
||||
$value = $default;
|
||||
}
|
||||
<<<<<<< Updated upstream
|
||||
elseif ($this->enforceExistingArguments && ! strpos($route, sprintf('[/{%s:', $variable)) ) {
|
||||
throw new \RuntimeException(sprintf("Error while preparing route %s : could not match variable '%s' into given arguments ( %s )", $route, $variable, json_encode($arguments)));
|
||||
=======
|
||||
elseif ($this->enforceExistingArguments) {dump($routeParam);
|
||||
throw new \RuntimeException(sprintf("Error while preparing route %s : could not match variable '%s' into given arguments ( %s ) from %s::%s", $route, $variable, json_encode($arguments), $routeParam['class'], $routeParam['classMethod']));
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user