github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

danceric / zfdebugdoctrine

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 25
    • 3
  • Source
  • Commits
  • Network (3)
  • Issues (0)
  • Downloads (1)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (1)
    • doctrine-1.1.x
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Doctrine ORM & Zend Framework & ZFDebug — Read more

  cancel

http://www.danceric.net/2009/06/06/zfdebug-and-doctrine-orm

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Changed setListener to addListener to not break already set Listeners 
robo47 (author)
Sun Jan 17 03:04:56 -0800 2010
danceric (committer)
Mon Jan 18 06:01:21 -0800 2010
commit  09c294f073703ed899c0ae31264b61704342ff76
tree    3a62947175afa5d183a287c90c31300084a267c7
parent  59d94a6b07b734800e2471b26cdd0cbf17fc8e1c
zfdebugdoctrine / library / Danceric / Controller / Plugin / Debug / Plugin / Doctrine.php library/Danceric/Controller/Plugin/Debug/Plugin/Doctrine.php
100644 117 lines (102 sloc) 3.267 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* ZFDebug Doctrine ORM plugin
*
* @category Danceric
* @package Danceric_Controller
* @subpackage Plugins
*/
 
/**
* @category Danceric
* @package Danceric_Controller
* @subpackage Plugins
*/
class Danceric_Controller_Plugin_Debug_Plugin_Doctrine extends ZFDebug_Controller_Plugin_Debug_Plugin implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface
{
    /**
* Contains plugin identifier name
*
* @var string
*/
    protected $_identifier = 'doctrine';
 
    /**
* @var array Doctrine connection profiler that will listen to events
*/
    protected $_profilers = array();
 
    /**
* Create ZFDebug_Controller_Plugin_Debug_Plugin_Variables
*
* @param Doctrine_Manager|array $options
* @return void
*/
    public function __construct(array $options = array())
    {
        if(!isset($options['manager']) || !count($options['manager'])) {
            if (Doctrine_Manager::getInstance()) {
                $options['manager'] = Doctrine_Manager::getInstance();
            }
        }
 
        foreach ($options['manager']->getIterator() as $connection) {
            $this->_profilers[$connection->getName()] = new Doctrine_Connection_Profiler();
            $connection->addListener($this->_profilers[$connection->getName()]);
        }
    }
 
    /**
* Gets identifier for this plugin
*
* @return string
*/
    public function getIdentifier()
    {
        return $this->_identifier;
    }
 
    /**
* Gets menu tab for the Debugbar
*
* @return string
*/
    public function getTab()
    {
        if (!$this->_profilers)
            return 'No Profiler';
 
        foreach ($this->_profilers as $profiler) {
            $time = 0;
            foreach ($profiler as $event) {
                $time += $event->getElapsedSecs();
            }
            $profilerInfo[] = $profiler->count() . ' in ' . round($time*1000, 2) . ' ms';
        }
        $html = implode(' / ', $profilerInfo);
 
        return $html;
    }
 
    /**
* Gets content panel for the Debugbar
*
* @return string
*/
    public function getPanel()
    {
        if (!$this->_profilers)
            return '';
 
        $html = '<h4>Database queries</h4>';
        
        foreach ($this->_profilers as $name => $profiler) {
                $html .= '<h4>Connection '.$name.'</h4><ol>';
                foreach ($profiler as $event) {
                    if (in_array($event->getName(), array('query', 'execute', 'exec'))) {
                        $info = htmlspecialchars($event->getQuery());
                    } else {
                        $info = '<em>' . htmlspecialchars($event->getName()) . '</em>';
                    }
 
                    $html .= '<li><strong>[' . round($event->getElapsedSecs()*1000, 2) . ' ms]</strong> ';
                    $html .= $info;
                
                    $params = $event->getParams();
                    if(!empty($params)) {
                        $html .= '<ul><em>bindings:</em> <li>'. implode('</li><li>', $params) . '</li></ul>';
                    }
                    $html .= '</li>';
                }
                $html .= '</ol>';
        }
 
        return $html;
    }
 
}
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server