[ Index ]
 

Code source de Symfony 1.0.0

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

title

Body

[fermer]

/lib/debug/ -> sfDebug.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   * sfDebug provides some method to help debugging a symfony application.
  13   *
  14   * @package    symfony
  15   * @subpackage debug
  16   * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
  17   * @version    SVN: $Id: sfDebug.class.php 3492 2007-02-18 09:10:54Z fabien $
  18   */
  19  class sfDebug
  20  {
  21    /**
  22     * Returns PHP information as an array.
  23     *
  24     * @return array An array of php information
  25     */
  26    public static function phpInfoAsArray()
  27    {
  28      $values = array(
  29        'php'        => phpversion(),
  30        'os'         => php_uname(),
  31        'extensions' => get_loaded_extensions(),
  32      );
  33  
  34      return $values;
  35    }
  36  
  37    /**
  38     * Returns PHP globals variables as a sorted array.
  39     *
  40     * @return array PHP globals
  41     */
  42    public static function globalsAsArray()
  43    {
  44      $values = array();
  45      foreach (array('cookie', 'server', 'get', 'post', 'files', 'env', 'session') as $name)
  46      {
  47        if (!isset($GLOBALS['_'.strtoupper($name)]))
  48        {
  49          continue;
  50        }
  51  
  52        $values[$name] = array();
  53        foreach ($GLOBALS['_'.strtoupper($name)] as $key => $value)
  54        {
  55          $values[$name][$key] = $value;
  56        }
  57        ksort($values[$name]);
  58      }
  59  
  60      ksort($values);
  61  
  62      return $values;
  63    }
  64  
  65    /**
  66     * Returns sfConfig variables as a sorted array.
  67     *
  68     * @return array sfConfig variables
  69     */
  70    public static function settingsAsArray()
  71    {
  72      $config = sfConfig::getAll();
  73  
  74      ksort($config);
  75  
  76      return $config;
  77    }
  78  
  79    /**
  80     * Returns request parameter holders as an array.
  81     *
  82     * @param sfRequest A sfRequest instance
  83     *
  84     * @return array The request parameter holders
  85     */
  86    public static function requestAsArray($request)
  87    {
  88      if ($request)
  89      {
  90        $values = array(
  91          'parameterHolder' => self::flattenParameterHolder($request->getParameterHolder()),
  92          'attributeHolder' => self::flattenParameterHolder($request->getAttributeHolder()),
  93        );
  94      }
  95      else
  96      {
  97        $values = array('parameterHolder' => array(), 'attributeHolder' => array());
  98      }
  99  
 100      return $values;
 101    }
 102  
 103    /**
 104     * Returns response parameters as an array.
 105     *
 106     * @param sfResponse A sfResponse instance
 107     *
 108     * @return array The response parameters
 109     */
 110    public static function responseAsArray($response)
 111    {
 112      if ($response)
 113      {
 114        $values = array(
 115          'cookies'         => array(),
 116          'httpHeaders'     => array(),
 117          'parameterHolder' => self::flattenParameterHolder($response->getParameterHolder()),
 118        );
 119        if (method_exists($response, 'getHttpHeaders'))
 120        {
 121          foreach ($response->getHttpHeaders() as $key => $value)
 122          {
 123            $values['httpHeaders'][$key] = $value;
 124          }
 125        }
 126  
 127        $cookies = array();
 128        foreach ($response->getCookies() as $key => $value)
 129        {
 130          $values['cookies'][$key] = $value;
 131        }
 132      }
 133      else
 134      {
 135        $values = array('cookies' => array(), 'httpHeaders' => array(), 'parameterHolder' => array());
 136      }
 137  
 138      return $values;
 139    }
 140  
 141    /**
 142     * Returns a parameter holder as an array.
 143     *
 144     * @param sfParameterHolder A sfParameterHolder instance
 145     *
 146     * @return array The parameter holder as an array
 147     */
 148    public static function flattenParameterHolder($parameterHolder)
 149    {
 150      $values = array();
 151      foreach ($parameterHolder->getNamespaces() as $ns)
 152      {
 153        $values[$ns] = array();
 154        foreach ($parameterHolder->getAll($ns) as $key => $value)
 155        {
 156          $values[$ns][$key] = $value;
 157        }
 158        ksort($values[$ns]);
 159      }
 160  
 161      ksort($values);
 162  
 163      return $values;
 164    }
 165  }


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