Fix logic error in view delegation thing

This commit is contained in:
Celestora 2021-12-27 14:08:52 +02:00
parent 624359f3f5
commit 5f839e1bb6

View file

@ -141,21 +141,17 @@ class Router
$this->scope += array_merge_recursive($presenter->getTemplateScope(), []); #TODO: add default parameters $this->scope += array_merge_recursive($presenter->getTemplateScope(), []); #TODO: add default parameters
#TODO: move this to delegateView #TODO: move this to delegateView
$tpl = "$presenterName/$action.xml"; $tpl = $this->scope["_template"] ?? "$presenterName/$action.xml";
if(!is_null($this->scope["_template"])) { if($tpl[0] !== "/") {
$tplCandidate = $this->scope["_template"]; $dir = CHANDLER_EXTENSIONS_ENABLED . "/$namespace/Web/Presenters/templates";
if($tplCandidate[0] !== "/") { $tpl = "$dir/$tplCandidate";
$dir = CHANDLER_EXTENSIONS_ENABLED . "/$namespace/Web/Presenters/templates"; if(isset($this->scope["_templatePath"]))
$tplCandidate = "$dir/$tplCandidate"; $tpl = str_replace($dir, $this->scope["_templatePath"], $tpl);
if(isset($this->scope["_templatePath"])) }
$tplCandidate = str_replace($dir, $this->scope["_templatePath"], $tplCandidate);
}
if(file_exists($tplCandidate)) { if(!file_exists($tpl)) {
$tpl = $tplCandidate; trigger_error("Could not open $tpl as template, falling back.", E_USER_NOTICE);
} else { $tpl = "$presenterName/$action.xml";
trigger_error("Could not open $tplCandidate as template, falling back to $tpl", E_USER_NOTICE);
}
} }
$output = $this->delegateView($tpl, $presenter); $output = $this->delegateView($tpl, $presenter);