本文整理汇总了PHP中Twig_Environment::getCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Environment::getCache方法的具体用法?PHP Twig_Environment::getCache怎么用?PHP Twig_Environment::getCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Environment
的用法示例。
在下文中一共展示了Twig_Environment::getCache方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* {@inheritdoc}
*/
public function compile($path, $reset = false)
{
if ($reset) {
$cache = $this->twig->getCache();
$this->twig->setCache(false);
}
$this->get($path);
if ($reset && !empty($cache)) {
//Restoring cache
$this->twig->setCache($cache);
}
}
示例2: loadTemplate
/**
* Loads a template by name.
*
* @param string $name The template name
* @param integer $index The index if it is an embedded template
*
* @return Twig_TemplateInterface A template instance representing the given template name
*/
public function loadTemplate($name, $index = null)
{
try {
return parent::loadTemplate($name, $index);
} catch (RuntimeException $excpt) {
$message = Ai1ec_I18n::__('We detected that your cache directory (%s) is not writable. This will make your calendar slow. Please contact your web host or server administrator to make it writable by the web server.');
$message = sprintf($message, $this->cache);
$this->_registry->get('notification.admin')->store($message, 'error', 1);
$settings = $this->_registry->get('model.settings');
/* @var $settings Ai1ec_Settings */
// used shutdown to store settings
// after this line exception occurs
$type = is_writable(parent::getCache()) ? 'AI1EC_CACHE_UNAVAILABLE' : '';
$settings->set('twig_cache', $type)->persist();
}
}
示例3: __destruct
public function __destruct()
{
$filesystem = new Filesystem();
$filesystem->remove($this->environment->getCache());
}
示例4: onCacheClear
/**
* Delete all cached templates
*/
public function onCacheClear()
{
if ($this->twig->getCache() and is_dir($this->twig->getCache())) {
$this->deleteTwigFilesFrom($this->twig->getCache());
}
}