Ejemplo n.º 1
0
 /**
  * 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;
         }
     }
 }
 /**
  * Sets the user as the current user in cache.
  *
  * @param Ai1ec_Facebook_Current_User $user
  */
 private function save_facebook_user_in_cache(Ai1ec_Facebook_Current_User $user)
 {
     try {
         $this->persistance_context->write_data_to_persistence(serialize($user));
     } catch (Ai1ec_Cache_Not_Set_Exception $excpt) {
         // we are on a slow lane
     }
 }