/** * Try to get the CSS from cache. * If it's not there re-generate it and save it to cache * If we are in preview mode, recompile the css using the theme present in the url. * */ public function get_compiled_css() { try { // If we want to force a recompile, we throw an exception. if (self::PARSE_LESS_FILES_AT_EVERY_REQUEST === true) { throw new Ai1ec_Cache_Not_Set_Exception(); } else { // This throws an exception if the key is not set $css = $this->persistance_context->get_data_from_persistence(); return $css; } } catch (Ai1ec_Cache_Not_Set_Exception $e) { $css = $this->lessphp_controller->parse_less_files(); try { $this->update_persistence_layer($css); return $css; } catch (Ai1ec_Cache_Write_Exception $e) { if (!self::PARSE_LESS_FILES_AT_EVERY_REQUEST) { $this->_registry->get('notification.admin')->store(sprintf(__('Your CSS is being compiled on every request, which causes your calendar to perform slowly. The following error occurred: %s', AI1EC_PLUGIN_NAME), $e->getMessage()), 'error', 2, array(Ai1ec_Notification_Admin::RCPT_ADMIN), true); } // If something is really broken, still return the css. // This means we parse it every time. This should never happen. return $css; } } }
/** * Try to get the CSS from cache. * If it's not there re-generate it and save it to cache * If we are in preview mode, recompile the css using the theme present in the url. * */ private function get_compiled_css() { try { // If we want to force a recompile, we throw an exception. if ($this->preview_mode === true || self::PARSE_LESS_FILES_AT_EVERY_REQUEST === true) { throw new Ai1ec_Cache_Not_Set_Exception(); } else { // This throws an exception if the key is not set $css = $this->persistance_context->get_data_from_persistence(); return $css; } } catch (Ai1ec_Cache_Not_Set_Exception $e) { // If we are in preview mode we force a recompile and we pass the variables. if ($this->preview_mode) { return $this->lessphp_controller->parse_less_files($this->lessphp_controller->get_less_variable_data_from_config_file()); } else { $css = $this->lessphp_controller->parse_less_files(); } try { $this->update_persistence_layer($css); return $css; } catch (Ai1ec_Cache_Write_Exception $e) { // If something is really broken, still return the css. // This means we parse it every time. This should never happen. return $css; } } }