From 5f839e1bb6a4005dd42c230efe0820fff63d6113 Mon Sep 17 00:00:00 2001 From: Celestora Date: Mon, 27 Dec 2021 14:08:52 +0200 Subject: [PATCH] Fix logic error in view delegation thing --- chandler/MVC/Routing/Router.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/chandler/MVC/Routing/Router.php b/chandler/MVC/Routing/Router.php index f426108..ecb245f 100644 --- a/chandler/MVC/Routing/Router.php +++ b/chandler/MVC/Routing/Router.php @@ -141,21 +141,17 @@ class Router $this->scope += array_merge_recursive($presenter->getTemplateScope(), []); #TODO: add default parameters #TODO: move this to delegateView - $tpl = "$presenterName/$action.xml"; - if(!is_null($this->scope["_template"])) { - $tplCandidate = $this->scope["_template"]; - if($tplCandidate[0] !== "/") { - $dir = CHANDLER_EXTENSIONS_ENABLED . "/$namespace/Web/Presenters/templates"; - $tplCandidate = "$dir/$tplCandidate"; - if(isset($this->scope["_templatePath"])) - $tplCandidate = str_replace($dir, $this->scope["_templatePath"], $tplCandidate); - } - - if(file_exists($tplCandidate)) { - $tpl = $tplCandidate; - } else { - trigger_error("Could not open $tplCandidate as template, falling back to $tpl", E_USER_NOTICE); - } + $tpl = $this->scope["_template"] ?? "$presenterName/$action.xml"; + if($tpl[0] !== "/") { + $dir = CHANDLER_EXTENSIONS_ENABLED . "/$namespace/Web/Presenters/templates"; + $tpl = "$dir/$tplCandidate"; + if(isset($this->scope["_templatePath"])) + $tpl = str_replace($dir, $this->scope["_templatePath"], $tpl); + } + + if(!file_exists($tpl)) { + trigger_error("Could not open $tpl as template, falling back.", E_USER_NOTICE); + $tpl = "$presenterName/$action.xml"; } $output = $this->delegateView($tpl, $presenter);