1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00
Co-authored-by: BernhardBaumrock <office@baumrock.com>
This commit is contained in:
Ryan Cramer
2022-11-10 11:44:29 -05:00
parent 78c2ca736d
commit 5aa0126b39

View File

@@ -1522,6 +1522,7 @@ class WireFileTools extends Wire {
)
);
// need to use different name than $options
$options = array_merge($defaults, $options);
$filename = trim($filename);
@@ -1562,27 +1563,33 @@ class WireFileTools extends Wire {
if(!file_exists($filename)) $this->filesException(__FUNCTION__, "File does not exist: $filename");
// remember options[func] and $filename outside this method because of the extract() which can overwrite
$this->includeFunc = $options['func'];
$this->includeFile = $filename;
// extract all API vars
$fuel = array_merge($this->wire()->fuel->getArray(), $vars);
extract($fuel);
// include the file
TemplateFile::pushRenderStack($filename);
$func = $options['func'];
if($func === 'require') {
require($filename);
} else if($func === 'require_once') {
require_once($filename);
} else if($func === 'include_once') {
include_once($filename);
TemplateFile::pushRenderStack($this->includeFile);
if($this->includeFunc === 'require') {
require($this->includeFile);
} else if($this->includeFunc === 'require_once') {
require_once($this->includeFile);
} else if($this->includeFunc === 'include_once') {
include_once($this->includeFile);
} else {
include($filename);
include($this->includeFile);
}
TemplateFile::popRenderStack();
return true;
}
protected $includeFunc = '';
protected $includeFile = '';
/**
* Same as include() method except that file will not be executed if it as previously been included
*