Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/DataCollector/RequestCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,22 +261,20 @@ protected function getRouteInformation($route)

if (isset($reflector)) {
$filename = $this->normalizeFilePath($reflector->getFileName());
$result['file'] = sprintf('%s:%s-%s', $filename, $reflector->getStartLine(), $reflector->getEndLine());

if ($link = $this->getXdebugLink($reflector->getFileName(), $reflector->getStartLine())) {
$result['file'] = sprintf(
'<a href="%s" onclick="%s" class="phpdebugbar-widgets-editor-link">%s:%s-%s</a>',
$link['url'],
$link['ajax'] ? 'event.preventDefault();$.ajax(this.href);' : '',
$filename,
$reflector->getStartLine(),
$reflector->getEndLine()
);
$result['file'] = [
'value' => $result['file'],
'xdebug_link' => $link,
];

if (isset($result['controller']) && is_string($result['controller'])) {
$result['controller'] .= '<a href="'.$link['url'].'" class="phpdebugbar-widgets-editor-link"></a>';
$result['controller'] = [
'value' => $result['controller'],
'xdebug_link' => $link,
];
}
} else {
$result['file'] = sprintf('%s:%s-%s', $filename, $reflector->getStartLine(), $reflector->getEndLine());
}
}

Expand Down
20 changes: 9 additions & 11 deletions src/DataCollector/RouteCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,20 @@ protected function getRouteInformation($route)

if (isset($reflector)) {
$filename = $this->normalizeFilePath($reflector->getFileName());
$result['file'] = sprintf('%s:%s-%s', $filename, $reflector->getStartLine(), $reflector->getEndLine());

if ($link = $this->getXdebugLink($reflector->getFileName(), $reflector->getStartLine())) {
$result['file'] = sprintf(
'<a href="%s" onclick="%s" class="phpdebugbar-widgets-editor-link">%s:%s-%s</a>',
$link['url'],
$link['ajax'] ? 'event.preventDefault();$.ajax(this.href);' : '',
$filename,
$reflector->getStartLine(),
$reflector->getEndLine()
);
$result['file'] = [
'value' => $result['file'],
'xdebug_link' => $link,
];

if (isset($result['controller'])) {
$result['controller'] .= '<a href="'.$link['url'].'" class="phpdebugbar-widgets-editor-link"></a>';
$result['controller'] = [
'value' => $result['controller'],
'xdebug_link' => $link,
];
}
} else {
$result['file'] = sprintf('%s:%s-%s', $filename, $reflector->getStartLine(), $reflector->getEndLine());
}
}

Expand Down
20 changes: 13 additions & 7 deletions tests/DataCollector/RouteCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testItCollectsRouteUri()
/**
* @dataProvider controllerData
*/
public function testItCollectsWithControllerHandler($controller, $file)
public function testItCollectsWithControllerHandler($controller, $file, $url)
{
$this->get('web/show');

Expand All @@ -45,21 +45,25 @@ public function testItCollectsWithControllerHandler($controller, $file)
$this->assertNotEmpty($collected);
$this->assertArrayHasKey('file', $collected);
$this->assertArrayHasKey('controller', $collected);
$this->assertStringContainsString($file, $collected['file']);
$this->assertStringContainsString($controller, $collected['controller']);
$this->assertStringContainsString($file, $collected['file']['value']);
$this->assertStringContainsString($url, $collected['file']['xdebug_link']['url']);
$this->assertStringContainsString($controller, $collected['controller']['value']);
$this->assertStringContainsString($url, $collected['controller']['xdebug_link']['url']);
}

/**
* @dataProvider viewComponentData
*/
public function testItCollectsWithViewComponentHandler($controller, $file)
public function testItCollectsWithViewComponentHandler($controller, $file, $url)
{
$this->get('web/view');

$collected = $this->routeCollector->collect();

$this->assertStringContainsString($file, $collected['file']);
$this->assertStringContainsString($controller, $collected['controller']);
$this->assertStringContainsString($file, $collected['file']['value']);
$this->assertStringContainsString($url, $collected['file']['xdebug_link']['url']);
$this->assertStringContainsString($controller, $collected['controller']['value']);
$this->assertStringContainsString($url, $collected['controller']['xdebug_link']['url']);
}

/**
Expand All @@ -75,7 +79,7 @@ public function testItCollectsWithClosureHandler($file)
$this->assertArrayHasKey('uses', $collected);
$this->assertArrayHasKey('file', $collected);
$this->assertStringContainsString($file, $collected['uses']);
$this->assertStringContainsString($file, $collected['file']);
$this->assertStringContainsString($file, $collected['file']['value']);
}

public function testItCollectsMiddleware()
Expand All @@ -93,6 +97,7 @@ public static function controllerData()
{
$filePath = urlencode(str_replace('\\', '/', realpath(__DIR__ . '/../Mocks/MockController.php')));
return [['MockController@show',
'MockController.php',
sprintf('phpstorm://open?file=%s', $filePath)
]];
}
Expand All @@ -101,6 +106,7 @@ public static function viewComponentData()
{
$filePath = urlencode(str_replace('\\', '/', realpath(__DIR__ . '/../Mocks/MockViewComponent.php')));
return [['MockViewComponent@render',
'MockViewComponent.php',
sprintf('phpstorm://open?file=%s', $filePath)
]];
}
Expand Down