ZF-10761: Add FirePhp 'Collapsed' option for GROUP_START message type

Description

The option that allows users to initialize the FirePHP console with items initially collapsed is currently not available. Users who use the FirePHP extensively for debugging, and viewing a variety of data will find it difficult to maneuver through data without closing unnecessary grouped items. The addition of this feature to the Zend Framework, which most likely already exists within the FirePHPCore class (see: http://www.firephp.org/HQ/Use.html), makes the FirePHP interface more usable in the context of ZF.

(Not sure I have permissions to upload, so here is the patch - inline.)


Index: library/Zend/Wildfire/Plugin/FirePhp.php
===================================================================
--- library/Zend/Wildfire/Plugin/FirePhp.php    (revision 23462)
+++ library/Zend/Wildfire/Plugin/FirePhp.php    (working copy)
@@ -322,12 +322,13 @@
     /**
      * Starts a group in the Firebug Console
      *
-     * @param string $title The title of the group
+     * @param  string  $title    The title of the group
+     * @param  array   $options  OPTIONAL Setting 'Collapsed' to true will initialize group collapsed instead of expanded
      * @return TRUE if the group instruction was added to the response headers or buffered.
      */
-    public static function group($title)
+    public static function group($title, $options = array())
     {
-        return self::send(null, $title, self::GROUP_START);
+        return self::send(null, $title, self::GROUP_START, $options);
     }
 
     /**
@@ -487,7 +488,13 @@
             unset($meta['File']);
             unset($meta['Line']);
         }
-
+        
+        if ($meta['Type'] == self::GROUP_START) {
+            if (isset($options['Collapsed']) && $options['Collapsed']) {
+                $meta['Collapsed'] = 'true';
+            }
+        }
+
         if ($meta['Type'] == self::DUMP) {
 
           return $firephp->_recordMessage(self::STRUCTURE_URI_DUMP,
    

Index: tests/Zend/Wildfire/WildfireTest.php
===================================================================
--- tests/Zend/Wildfire/WildfireTest.php    (revision 23462)
+++ tests/Zend/Wildfire/WildfireTest.php    (working copy)
@@ -604,7 +604,28 @@
 
         $this->assertTrue($this->_response->verifyHeaders($headers));
     }
+    
+    public function testMessageGroupsWithCollapsedOption()
+    {
+        $this->_setupWithFrontController();
 
+        Zend_Wildfire_Plugin_FirePhp::group('Test Group', array('Collapsed' => true));
+        Zend_Wildfire_Plugin_FirePhp::send('Test Message');
+        Zend_Wildfire_Plugin_FirePhp::groupEnd();
+
+        $this->_controller->dispatch();
+
+        $headers = array();
+        $headers['X-Wf-Protocol-1'] = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2';
+        $headers['X-Wf-1-Structure-1'] = 'http://meta.firephp.org/Wildfire/Structure/…';
+        $headers['X-Wf-1-Plugin-1'] = 'http://meta.firephp.org/Wildfire/Plugin/…';
+        $headers['X-Wf-1-1-1-1'] = '69|[{"Type":"GROUP_START","Label":"Test Group","Collapsed":"true"},null]|';
+        $headers['X-Wf-1-1-1-2'] = '31|[{"Type":"LOG"},"Test Message"]|';
+        $headers['X-Wf-1-1-1-3'] = '27|[{"Type":"GROUP_END"},null]|';
+
+        $this->assertTrue($this->_response->verifyHeaders($headers));
+    }
+
     public function testMessageComparison()
     {
         $label = 'Message';

Comments

This patch break BC should be used func_get_arg(s).

In what way does it break BC? We are only adding a parameter to group(), which shouldn't affect anything b/c the original function only uses one parameter, $title. What are you seeing?

This patch should be fine. We'll need a unit test as well that verifies the header output with the option set.

Added patch for WildfireTest.php unit test.

looks good to me. Have not tested. Thanks!

These patches can be applied by anyone. I'll try and get to it next week.