Federico Cargnelutti

Simple is better than complex. Complex is better than complicated. | @fedecarg

Customize the Symfony Web Debug Toolbar

leave a comment »

Fabien Potencier wrote:

The Symfony Web debug toolbar is one of the developer best friend. It is always conveniently accessible in the browser when using the development environment. It gives you everything you need to know about the current page and ease the debugging of your applications. Until now, the information in this toolbar was hardcoded. But as of Symfony 1.2, the Web debug toolbar is entirely configurable. The new toolbar is composed of panels. Each panel is composed of a title and an optional panel content, and the panel is represented by a PHP object.

sfWebDebugPanelAssets class

class sfWebDebugPanelAssets extends sfWebDebugPanel
{
  public function getTitle()
  {
    return 'assets';
  }

  public function getPanelTitle()
  {
    return 'Stylesheet and JavaScript files from sfWebResponse';
  }

  public function getPanelContent()
  {
    return null;
  }
}

frontendConfiguration class

class frontendConfiguration extends sfApplicationConfiguration
{
  public function configure()
  {
    $this->dispatcher->connect('debug.web.load_panels', array($this, 'configureWebDebugToolbar'));
  }

  public function configureWebDebugToolbar(sfEvent $event)
  {
    $webDebugToolbar = $event->getSubject();
    $assetsPanel = new sfWebDebugPanelAssets($webDebugToolbar);
    $webDebugToolbar->setPanel('assets', $assetsPanel);
  }
}

Links

Advertisement

Written by Federico

August 28, 2008 at 3:18 pm

Posted in Frameworks, PHP, Programming

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 43 other followers