-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BlueScreen: added kick-ass bluescreen with validation details
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Apitte\Debug\Tracy\BlueScreen; | ||
|
||
use Apitte\Core\Exception\Logical\InvalidSchemaException; | ||
use ReflectionClass; | ||
use Tracy\BlueScreen; | ||
use Tracy\Helpers; | ||
|
||
final class ValidationBlueScreen | ||
{ | ||
|
||
/** | ||
* @param BlueScreen $blueScreen | ||
* @return void | ||
*/ | ||
public static function register(BlueScreen $blueScreen) | ||
{ | ||
$blueScreen->addPanel(function ($e) { | ||
if (!($e instanceof InvalidSchemaException)) return; | ||
|
||
return [ | ||
'tab' => self::renderTab($e), | ||
'panel' => self::renderPanel($e), | ||
]; | ||
}); | ||
} | ||
|
||
/** | ||
* @param InvalidSchemaException $e | ||
* @return string | ||
*/ | ||
private static function renderTab(InvalidSchemaException $e) | ||
{ | ||
return 'Apitte - Validation'; | ||
} | ||
|
||
/** | ||
* @param InvalidSchemaException $e | ||
* @return mixed | ||
*/ | ||
private static function renderPanel(InvalidSchemaException $e) | ||
{ | ||
if (!$e->controller || !$e->method) return NULL; | ||
|
||
$rf = new ReflectionClass($e->controller->getClass()); | ||
$rm = $rf->getMethod($e->method->getName()); | ||
|
||
return '<p><b>File:</b>' . Helpers::editorLink($rf->getFileName(), $rm->getStartLine()) . '</p>' | ||
. BlueScreen::highlightFile($rf->getFileName(), $rm->getStartLine(), 20); | ||
} | ||
|
||
} |