Development

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

You must first sign up to be able to contribute.

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

Revision 16942, 1.8 kB (checked in by fabien, 5 years ago)

[1.0, 1.1, 1.2, 1.3] removed the web debug toolbar when the response status code is in the 3xx range (closes #6153)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
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  *
13  * @package    symfony
14  * @subpackage filter
15  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
16  * @version    SVN: $Id$
17  */
18 class sfWebDebugFilter extends sfFilter
19 {
20   /**
21    * Executes this filter.
22    *
23    * @param sfFilterChain A sfFilterChain instance
24    */
25   public function execute($filterChain)
26   {
27     // execute this filter only once
28     if ($this->isFirstCall())
29     {
30       // register sfWebDebug assets
31       sfWebDebug::getInstance()->registerAssets();
32     }
33
34     // execute next filter
35     $filterChain->execute();
36
37     $context    = $this->getContext();
38     $response   = $context->getResponse();
39     $controller = $context->getController();
40
41     // don't add debug toolbar:
42     // * for XHR requests
43     // * if response status code is in the 3xx range
44     // * if not rendering to the client
45     // * if HTTP headers only
46     if (
47       $this->getContext()->getRequest()->isXmlHttpRequest() ||
48       strpos($response->getContentType(), 'html') === false ||
49       '3' == substr($response->getStatusCode(), 0, 1) ||
50       $controller->getRenderMode() != sfView::RENDER_CLIENT ||
51       $response->isHeaderOnly()
52     )
53     {
54       return;
55     }
56
57     $content  = $response->getContent();
58     $webDebug = sfWebDebug::getInstance()->getResults();
59
60     // add web debug information to response content
61     $newContent = str_ireplace('</body>', $webDebug.'</body>', $content);
62     if ($content == $newContent)
63     {
64       $newContent .= $webDebug;
65     }
66
67     $response->setContent($newContent);
68   }
69 }
70
Note: See TracBrowser for help on using the browser.