Author: Jonathan.Wage
Date: 2010-01-17 03:08:36 +0100 (Sun, 17 Jan 2010)
New Revision: 26746

Modified:
   plugins/sfSympalPlugin/trunk/lib/core/sfSympalConfiguration.class.php
Log:
[1.4][sfSympalPlugin][1.0] Trying functionality to try clearing the cache one 
time when an exception is thrown


Modified: plugins/sfSympalPlugin/trunk/lib/core/sfSympalConfiguration.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/core/sfSympalConfiguration.class.php       
2010-01-17 00:59:06 UTC (rev 26745)
+++ plugins/sfSympalPlugin/trunk/lib/core/sfSympalConfiguration.class.php       
2010-01-17 02:08:36 UTC (rev 26746)
@@ -43,6 +43,8 @@
     $this->_dispatcher->connect('form.post_configure', array('sfSympalForm', 
'listenToFormPostConfigure'));
     $this->_dispatcher->connect('form.filter_values', array('sfSympalForm', 
'listenToFormFilterValues'));
     $this->_dispatcher->connect('routing.load_configuration', array($this, 
'listenToRoutingLoadConfiguration'));
+    $this->_dispatcher->connect('routing.load_configuration', array($this, 
'listenToRoutingLoadConfiguration'));
+    $this->_dispatcher->connect('application.throw_exception', array($this, 
'listenToApplicationThrowException'));
 
     if (sfSympalConfig::get('page_cache', 'super') && 
sfConfig::get('sf_cache'))
     {
@@ -58,6 +60,26 @@
     
Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_COLLECTION_CLASS,
 'sfSympalDoctrineCollection');
   }
 
+  public function listenToApplicationThrowException(sfEvent $event)
+  {
+    try {
+      $user = $this->_symfonyContext->getUser();
+      if ($user->isEditMode() && 
$this->_symfonyContext->getRequest()->isMethod('get'))
+      {
+        if (!$user->getAttribute('sf_sympal_exception_cache_cleared'))
+        {
+          chdir(sfConfig::get('sf_root_dir'));
+          $task = new sfCacheClearTask($this->_dispatcher, new sfFormatter());
+          $task->run(array(), array());
+          
$this->_symfonyContext->getUser()->setAttribute('sf_sympal_exception_cache_cleared',
 true);
+          
$this->_symfonyContext->getController()->redirect($this->_symfonyContext->getRequest()->getUri());
+        } else {
+          
$this->_symfonyContext->getUser()->setAttribute('sf_sympal_exception_cache_cleared',
 false);
+        }
+      }
+    } catch (Exception $e) {}
+  }
+
   public function listenToTaskCacheClear(sfEvent $event)
   {
     $event->getSubject()->logSection('sympal', 'Clearing web cache folder');

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.


Reply via email to