[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/filter/ -> sfFlashFilter.class.php (source)

   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: sfFlashFilter.class.php 3244 2007-01-12 14:46:11Z fabien $
  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  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7