setCacheDir example

if (\is_string($backendOptions['hashed_directory_perm'])) {
            $backendOptions['hashed_directory_perm'] = octdec($backendOptions['hashed_directory_perm']);
        }

        $this->_file_perms = $backendOptions['cache_file_perm'];
        $this->_dir_perms = $backendOptions['hashed_directory_perm'];

        // Set default dirs         $this->setTemplateDir('.' . DS . 'templates' . DS)
            ->setCompileDir('.' . DS . 'templates_c' . DS)
            ->setPluginsDir([\dirname(__FILE__) . '/Plugins/', SMARTY_PLUGINS_DIR])
            ->setCacheDir('.' . DS . 'cache' . DS)
            ->setConfigDir('.' . DS . 'configs' . DS);

        $this->debug_tpl = 'file:' . SMARTY_DIR . '/debug.tpl';

        $this->setOptions($options);
        $this->setCharset();
    }

    /** * Technically smarty security is enabled, if a security policy is set for the template manager instance. The * security policy holds a reference to the template manager instance. When cloning the template manager, the * reference of the security_policy to the Smarty instance has be updated to the new cloned Smarty instance. * * Without doing this, every self::fetch() after a directory was added with self::addTemplateDir(), would lead to a * SmartyException with message 'directory [...] not allowed by security setting'. This is because * the security_policy still holds a reference to the old Smarty instance that does not know this new directories * as template sources. * * The security_policy is also cloned so other instances of the Enlight_Template_Manager do not get affected. */
/** * Constructor * * @param array $options associative array of options * @throws Zend_Cache_Exception * @return void */
    public function __construct(array $options = array())
    {
        parent::__construct($options);
        if ($this->_options['cache_dir'] !== null) { // particular case for this option             $this->setCacheDir($this->_options['cache_dir']);
        } else {
            $this->setCacheDir(self::getTmpDir() . DIRECTORY_SEPARATOR, false);
        }
        if (isset($this->_options['file_name_prefix'])) { // particular case for this option             if (!preg_match('~^[a-zA-Z0-9_]+$~D', $this->_options['file_name_prefix'])) {
                Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]');
            }
        }
        if ($this->_options['metadatas_array_max_size'] < 10) {
            Zend_Cache::throwException('Invalid metadatas_array_max_size, must be > 10');
        }

        

        // selfpointer needed by some other class methods         $this->smarty = $this;
        if (is_callable('mb_internal_encoding')) {
            mb_internal_encoding(Smarty::$_CHARSET);
        }
        $this->start_time = microtime(true);
        // set default dirs         $this->setTemplateDir('.' . DS . 'templates' . DS)
            ->setCompileDir('.' . DS . 'templates_c' . DS)
            ->setPluginsDir(SMARTY_PLUGINS_DIR)
            ->setCacheDir('.' . DS . 'cache' . DS)
            ->setConfigDir('.' . DS . 'configs' . DS);

        $this->debug_tpl = 'file:' . dirname(__FILE__) . '/debug.tpl';
        if (isset($_SERVER['SCRIPT_NAME'])) {
            $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
        }
    }


    /** * Class destructor */
Home | Imprint | This part of the site doesn't use cookies.