Compare commits
	
		
			2 Commits
		
	
	
		
			169400cd61
			...
			1611ebe047
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1611ebe047 | |||
| 6ee3e1bbae | 
@ -24,6 +24,9 @@ PATTERN;
 | 
			
		||||
 | 
			
		||||
    public array $tokens = [ "url" , "route", "asset", "slug" ];
 | 
			
		||||
 | 
			
		||||
    #[\Deprecated]
 | 
			
		||||
    protected bool $enforceExistingArguments = true;
 | 
			
		||||
 | 
			
		||||
    public function __construct(string $urlBase = "", string $assetToken = "") {
 | 
			
		||||
        $this->urlBase = trim($urlBase, "/");
 | 
			
		||||
        $this->assetToken = $assetToken;
 | 
			
		||||
@ -216,26 +219,34 @@ PATTERN;
 | 
			
		||||
            $search = [];
 | 
			
		||||
 | 
			
		||||
            foreach($matches as $item) {
 | 
			
		||||
                if (strpos($item[1], "=") !== false) {
 | 
			
		||||
                $default = null;
 | 
			
		||||
 | 
			
		||||
                $variable = $item[1];
 | 
			
		||||
 | 
			
		||||
                # Handles default
 | 
			
		||||
                if (strpos($variable, "=") !== false) {
 | 
			
		||||
                    list($variable, $default) = explode('=', $item[1]);
 | 
			
		||||
                }
 | 
			
		||||
                elseif (strpos($item[1], ":") !== false) {
 | 
			
		||||
 | 
			
		||||
                # Handles type
 | 
			
		||||
                if (strpos($variable, ":") !== false) {
 | 
			
		||||
                    list($variable, ) = explode(':', $item[1]);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    $variable = $item[1];
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if ( array_key_exists($variable, $arguments) ) {
 | 
			
		||||
                    $value = $arguments[ $variable ];
 | 
			
		||||
                    unset($arguments[ $variable ]);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    $value = $default ?? "";
 | 
			
		||||
                    if ($default ?? false) {
 | 
			
		||||
                        $value = $default;
 | 
			
		||||
                    }
 | 
			
		||||
                    elseif ($this->enforceExistingArguments) {
 | 
			
		||||
                        throw new \RuntimeException(sprintf("Error while preparing route %s : could not match variable '%s' into given arguments ( %s )", $route, $variable, json_encode($arguments)));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                $search[ $item[0] ] = $value;
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $route = str_replace(array_keys($search), array_values($search), $route);
 | 
			
		||||
 | 
			
		||||
@ -71,12 +71,12 @@ class Picea implements LanguageRegistration
 | 
			
		||||
            return call_user_func($object);
 | 
			
		||||
        }
 | 
			
		||||
        catch(\Throwable $ex) {
 | 
			
		||||
            if (! $ex instanceof Exception\RenderHtmlException ) {
 | 
			
		||||
                throw new Exception\RenderHtmlException($object, $this, "An error occurred trying to render HTML view `$viewPath` : " . $ex->getMessage(), 911, $ex);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
            #if (! $ex instanceof Exception\RenderHtmlException ) {
 | 
			
		||||
              # throw new Exception\RenderHtmlException($object, $this, "An error occurred trying to render HTML view `$viewPath` : " . $ex->getMessage(), 911, $ex);
 | 
			
		||||
            #}
 | 
			
		||||
            #else {
 | 
			
		||||
                throw $ex;
 | 
			
		||||
            }
 | 
			
		||||
            #}
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        exit();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user