Development

/branches/1.0/lib/filter/sfFlashFilter.class.php

You must first sign up to be able to contribute.

root/branches/1.0/lib/filter/sfFlashFilter.class.php

Revision 3244, 1.8 kB (checked in by fabien, 8 years ago)

updated lib/filter/ directory phpdoc

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfFlashFilter removes flash attributes from the session.
13  *
14  * @package    symfony
15  * @subpackage filter
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfFlashFilter extends sfFilter
20 {
21   /**
22    * Executes this filter.
23    *
24    * @param sfFilterChain A sfFilterChain instance.
25    */
26   public function execute($filterChain)
27   {
28     $context = $this->getContext();
29     $userAttributeHolder = $context->getUser()->getAttributeHolder();
30
31     // execute this filter only once
32     if ($this->isFirstCall())
33     {
34       // flag current flash to be removed after the execution filter
35       $names = $userAttributeHolder->getNames('symfony/flash');
36       if ($names)
37       {
38         if (sfConfig::get('sf_logging_enabled'))
39         {
40           $context->getLogger()->info('{sfFilter} flag old flash messages ("'.implode('", "', $names).'")');
41         }
42         foreach ($names as $name)
43         {
44           $userAttributeHolder->set($name, true, 'symfony/flash/remove');
45         }
46       }
47     }
48
49     // execute next filter
50     $filterChain->execute();
51
52     // remove flash that are tagged to be removed
53     $names = $userAttributeHolder->getNames('symfony/flash/remove');
54     if ($names)
55     {
56       if (sfConfig::get('sf_logging_enabled'))
57       {
58         $context->getLogger()->info('{sfFilter} remove old flash messages ("'.implode('", "', $names).'")');
59       }
60       foreach ($names as $name)
61       {
62         $userAttributeHolder->remove($name, 'symfony/flash');
63         $userAttributeHolder->remove($name, 'symfony/flash/remove');
64       }
65     }
66   }
67 }
68
Note: See TracBrowser for help on using the browser.