mithra62/ee_debug_toolbar — pull request #16 by mithra62 (2013-02-19 21:19:33+00:00)
Title: Hookah

Here's what I have for an extensible Toolbar.

I added a new hook called "ee_debug_toolbar_modify_output" which gets passed the entire view array within the ext class. The idea is that extensions will be able to modify the values thus allowing for overriding of pretty much everything.

To start, I broke the theme view data into an array that gets iterated from within the view. Because it's an array though the extensions can change meta info about the panels, adding new panel meta info, removing panels, and changing panel details.

The panel meta info is stored in extension file around line 178 (we should discuss the technical debt this'll cause) and contains 4 options.

## Adding A Panel ##
While the Panel HTML themselves are to come from view scripts from the third party extension (loaded by the toolbar.php view script), if the extension wants to add additional panels they'll need to provide the meta info as an array with the below keys.

**view\_script**: The view script to use for the given panel. This can be relative to the extension.
**image**: The URL to the image to use for the panel icon.
**title**: What copy to use for the panel stub.
**data\_target**: The ID for the div surrounding the panel you want to open on click.
**class**: Any CSS class you want to use on the span on the panel stub.

**Example**:

`$report_info['panel_data']['variables']['view_script'] = 'partials/variables';`

`$report_info['panel_data']['variables']['image'] = $vars['theme_img_url'].'variables.png';`

`$report_info['panel_data']['variables']['title'] = lang('variables');`

`$report_info['panel_data']['variables']['data_target'] = 'EEDebug_variables';`

`$report_info['panel_data']['variables']['class'] = '';`

## Removing A Panel ##
To remove a panel all that needs to happen is that the panel data be removed from the view data.

**Example**:

To remove the "variables" panel just unset it.

`unset($view['panel_data['variables']);`

## Ordering Panels ##

The panels are displayed in the order in the array they appear so reordering is a simple matter of rearranging the array.

## Extension Prototype ##

`public function my_custom_toolbar($view_vars)
{
$view_vars = ($this->EE->extensions->last_call != '' ? $this->EE->extensions->last_call : $view_vars);

//do stuff

return $view_vars;
}`