mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 11:11:39 +09:00
Reset template configuration when paths are provided to compile() or compileDirect()
This commit is contained in:
parent
a5d6a76cf4
commit
8d3a332344
1 changed files with 18 additions and 6 deletions
|
|
@ -72,16 +72,13 @@ class Template
|
||||||
*/
|
*/
|
||||||
public function __construct(?string $dirname = null, ?string $filename = null, ?string $extension = null)
|
public function __construct(?string $dirname = null, ?string $filename = null, ?string $extension = null)
|
||||||
{
|
{
|
||||||
// Set instance configuration to default values.
|
// Initialize configuration.
|
||||||
$this->config = new \stdClass;
|
$this->_initConfig();
|
||||||
$this->config->version = 1;
|
|
||||||
$this->config->autoescape = false;
|
|
||||||
$this->config->context = 'HTML';
|
|
||||||
|
|
||||||
// Set user information.
|
// Set user information.
|
||||||
$this->user = Session::getMemberInfo() ?: new Helpers\SessionHelper();
|
$this->user = Session::getMemberInfo() ?: new Helpers\SessionHelper();
|
||||||
|
|
||||||
// Cache commonly used configurations as static properties.
|
// Populate static properties for optimization.
|
||||||
if (self::$_mtime === null)
|
if (self::$_mtime === null)
|
||||||
{
|
{
|
||||||
self::$_mtime = filemtime(__FILE__);
|
self::$_mtime = filemtime(__FILE__);
|
||||||
|
|
@ -102,6 +99,19 @@ class Template
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the configuration object.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function _initConfig(): void
|
||||||
|
{
|
||||||
|
$this->config = new \stdClass;
|
||||||
|
$this->config->version = 1;
|
||||||
|
$this->config->autoescape = false;
|
||||||
|
$this->config->context = 'HTML';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize and normalize paths.
|
* Initialize and normalize paths.
|
||||||
*
|
*
|
||||||
|
|
@ -295,6 +305,7 @@ class Template
|
||||||
// If paths are given, initialize now.
|
// If paths are given, initialize now.
|
||||||
if ($dirname && $filename)
|
if ($dirname && $filename)
|
||||||
{
|
{
|
||||||
|
$this->_initConfig();
|
||||||
$this->_setSourcePath($dirname, $filename);
|
$this->_setSourcePath($dirname, $filename);
|
||||||
}
|
}
|
||||||
if ($override_filename)
|
if ($override_filename)
|
||||||
|
|
@ -362,6 +373,7 @@ class Template
|
||||||
public function compileDirect(string $dirname, string $filename): string
|
public function compileDirect(string $dirname, string $filename): string
|
||||||
{
|
{
|
||||||
// Initialize paths. Return error if file does not exist.
|
// Initialize paths. Return error if file does not exist.
|
||||||
|
$this->_initConfig();
|
||||||
$this->_setSourcePath($dirname, $filename);
|
$this->_setSourcePath($dirname, $filename);
|
||||||
if (!$this->exists)
|
if (!$this->exists)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue