1: <?php
2:
3: 4: 5: 6:
7:
8: namespace Nette\Bridges\Framework;
9:
10: use Nette;
11: use Nette\Framework;
12: use Tracy;
13: use Tracy\Helpers;
14: use Tracy\BlueScreen;
15: use Latte;
16:
17:
18: 19: 20:
21: class TracyBridge
22: {
23:
24: public static function initialize()
25: {
26: $blueScreen = Tracy\Debugger::getBlueScreen();
27:
28: if (class_exists('Nette\Framework')) {
29: $bar = Tracy\Debugger::getBar();
30: $bar->info[] = $blueScreen->info[] = 'Nette Framework ' . Framework::VERSION
31: . (Framework::REVISION ? ' (' . Framework::REVISION . ')' : '');
32: }
33:
34: $blueScreen->addPanel(function ($e) {
35: if ($e instanceof Latte\CompileException) {
36: return array(
37: 'tab' => 'Template',
38: 'panel' => (@is_file($e->sourceName)
39: ? '<p><b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) . '</p>'
40: : '')
41: . '<pre>'
42: . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode, ENT_IGNORE, 'UTF-8'), $e->sourceLine)
43: . '</pre>',
44: );
45: }
46: });
47:
48: $blueScreen->addPanel(function ($e) {
49: if ($e instanceof Nette\Neon\Exception && preg_match('#line (\d+)#', $e->getMessage(), $m)
50: && ($trace = Helpers::findTrace($e->getTrace(), 'Nette\Neon\Decoder::decode'))
51: ) {
52: return array(
53: 'tab' => 'NEON',
54: 'panel' => ($trace2 = Helpers::findTrace($e->getTrace(), 'Nette\DI\Config\Adapters\NeonAdapter::load'))
55: ? '<p><b>File:</b> ' . Helpers::editorLink($trace2['args'][0], $m[1]) . '</p>'
56: . BlueScreen::highlightFile($trace2['args'][0], $m[1])
57: : BlueScreen::highlightPhp($trace['args'][0], $m[1]),
58: );
59: }
60: });
61: }
62:
63: }
64: