Box\Brainy\Templates\Template::decodeProperties PHP Method

decodeProperties() public method

This function is executed automatically when a compiled or cached template file is included
public decodeProperties ( array $properties ) : boolean
$properties array special template properties
return boolean flag if compiled or cache file is valid
    public function decodeProperties($properties)
    {
        if (isset($properties['file_dependency'])) {
            foreach ($properties['file_dependency'] as $key => $val) {
                $this->properties['file_dependency'][$key] = $val;
            }
        }
        $this->properties['version'] = isset($properties['version']) ? $properties['version'] : '';
        // check file dependencies at compiled code
        if ($this->properties['version'] != Brainy::SMARTY_VERSION) {
            return false;
        }
        if ($this->smarty->compile_check && empty($this->compiled->properties) && !$this->compiled->isCompiled && !empty($this->properties['file_dependency'])) {
            foreach ($this->properties['file_dependency'] as $_file_to_check) {
                if ($_file_to_check[2] == 'file') {
                    if ($this->source->filepath == $_file_to_check[0] && isset($this->source->timestamp)) {
                        // do not recheck current template
                        $mtime = $this->source->timestamp;
                    } else {
                        // file and php types can be checked without loading the respective resource handlers
                        $mtime = @filemtime($_file_to_check[0]);
                    }
                } elseif ($_file_to_check[2] == 'string') {
                    continue;
                } else {
                    $source = \Box\Brainy\Resources\Resource::source(null, $this->smarty, $_file_to_check[0]);
                    $mtime = $source->timestamp;
                }
                if (!$mtime || $mtime > $_file_to_check[1]) {
                    return false;
                }
            }
        }
        // store data in reusable Smarty_Template_Compiled
        $this->properties['unifunc'] = $properties['unifunc'];
        $this->compiled->properties = $properties;
        return true;
    }