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
1 changed files with 11 additions and 15 deletions

View File

@ -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);