mirror of
https://github.com/openvk/chandler.git
synced 2025-01-22 15:24:15 +03:00
[WIP] Add fallback to overriden templates
This commit is contained in:
parent
1e45ef5ef7
commit
624359f3f5
1 changed files with 15 additions and 6 deletions
|
@ -141,12 +141,21 @@ 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 = $this->scope["_template"] ?? "$presenterName/$action.xml";
|
$tpl = "$presenterName/$action.xml";
|
||||||
if($tpl[0] !== "/") {
|
if(!is_null($this->scope["_template"])) {
|
||||||
$dir = CHANDLER_EXTENSIONS_ENABLED . "/$namespace/Web/Presenters/templates";
|
$tplCandidate = $this->scope["_template"];
|
||||||
$tpl = "$dir/$tpl";
|
if($tplCandidate[0] !== "/") {
|
||||||
if(isset($this->scope["_templatePath"]))
|
$dir = CHANDLER_EXTENSIONS_ENABLED . "/$namespace/Web/Presenters/templates";
|
||||||
$tpl = str_replace($dir, $this->scope["_templatePath"], $tpl);
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = $this->delegateView($tpl, $presenter);
|
$output = $this->delegateView($tpl, $presenter);
|
||||||
|
|
Loading…
Reference in a new issue