Ejemplo n.º 1
0
 /**
  * Clear cache.
  * 
  * @todo Clear templates.
  */
 public function showClearCache()
 {
     $this->addMainMenu();
     Curry_Core::$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     Curry_Twig_Template::getSharedEnvironment()->clearCacheFiles();
     if (extension_loaded('apc')) {
         @apc_clear_cache();
     }
     $this->addMessage('Cache cleaned', self::MSG_SUCCESS);
 }
Ejemplo n.º 2
0
 /**
  * Render a page and return content.
  *
  * @param array $vars
  * @param array $options
  * @return string
  */
 public function render(array $vars = array(), array $options = array())
 {
     $twig = Curry_Twig_Template::getSharedEnvironment();
     // Todo: Rename curry to app?
     $appVars = Curry_Application::getInstance()->getGlobalVariables();
     if (isset($vars['curry'])) {
         Curry_Array::extend($appVars, $vars['curry']);
     }
     $vars['curry'] = Curry_Array::extend($appVars, $this->getGlobals());
     foreach ($vars as $k => $v) {
         $twig->addGlobal($k, $v);
     }
     $moduleContent = $this->generate($options);
     if (isset($options['pageModuleId'])) {
         $pageModuleId = $options['pageModuleId'];
         $pageModuleWrappers = $this->getPageModuleWrappers();
         if (isset($pageModuleWrappers[$pageModuleId])) {
             $pageModuleWrapper = $pageModuleWrappers[$pageModuleId];
             return $moduleContent[$pageModuleWrapper->getTarget()];
         } else {
             throw new Exception('PageModule with id = ' . $pageModuleId . ' not found on page.');
         }
     }
     $template = $this->getTemplateObject();
     return $this->renderTemplate($template, $moduleContent);
 }