Skip to content

Commit 65ad97c

Browse files
amenkbarryvdh
authored andcommitted
Add Xdebug Link functionality (#303)
barryvdh/laravel-debugbar#566
1 parent 3c82244 commit 65ad97c

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/DebugBar/DataCollector/DataCollector.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ public function getDataFormatter()
7272
}
7373

7474
/**
75+
* Get an Xdebug Link to a file
76+
*
77+
* @return string|null
78+
*/
79+
public function getXdebugLink($file, $line = 1)
80+
{
81+
if (ini_get('xdebug.file_link_format') || extension_loaded('xdebug')) {
82+
return e(str_replace(array('%f', '%l'), array($file, $line), ini_get('xdebug.file_link_format')));
83+
}
84+
}
85+
86+
/**
7587
* Sets the default variable dumper used by all collectors subclassing this class
7688
*
7789
* @param DebugBarVarDumper $varDumper

src/DebugBar/Resources/widgets/templates/widget.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ div.phpdebugbar-widgets-templates div.phpdebugbar-widgets-status span.phpdebugba
2525
div.phpdebugbar-widgets-templates span.phpdebugbar-widgets-render-time:before,
2626
div.phpdebugbar-widgets-templates span.phpdebugbar-widgets-memory:before,
2727
div.phpdebugbar-widgets-templates span.phpdebugbar-widgets-param-count:before,
28-
div.phpdebugbar-widgets-templates span.phpdebugbar-widgets-type:before {
28+
div.phpdebugbar-widgets-templates span.phpdebugbar-widgets-type:before,
29+
div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before
30+
{
2931
font-family: PhpDebugbarFontAwesome;
3032
margin-right: 4px;
3133
font-size: 12px;
@@ -42,6 +44,10 @@ div.phpdebugbar-widgets-templates span.phpdebugbar-widgets-param-count:before {
4244
div.phpdebugbar-widgets-templates span.phpdebugbar-widgets-type:before {
4345
content: "\f121";
4446
}
47+
div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before {
48+
content: "\f08e";
49+
margin-left: 4px;
50+
}
4551
div.phpdebugbar-widgets-templates table.phpdebugbar-widgets-params {
4652
display: none;
4753
width: 70%;

src/DebugBar/Resources/widgets/templates/widget.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
this.$list = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, tpl) {
1919
$('<span />').addClass(csscls('name')).text(tpl.name).appendTo(li);
20+
21+
if (typeof tpl.xdebug_link != 'undefined') {
22+
$('<a href="' + tpl.xdebug_link + '"></a>').addClass(csscls('editor-link')).appendTo(li);
23+
}
2024
if (tpl.render_time_str) {
2125
$('<span title="Render time" />').addClass(csscls('render-time')).text(tpl.render_time_str).appendTo(li);
2226
}

0 commit comments

Comments
 (0)