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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ $ composer require illuminate/database

**2.2** add to your dependencies (Twig, Twig_Profiler) and/or Eloquent ORM like:
```php
// Twig
// Twig 1
$c['twig_profile'] = function () {
return new Twig_Profiler_Profile();
};
Expand All @@ -71,6 +71,14 @@ $c['view'] = function ($c) {
return $view;
};

// Twig 3
$c['twig_profile'] = function () {
return new \Twig\Profiler\Profile();
};
...
$view->addExtension(new \Twig\Extension\ProfilerExtension($c['twig_profile']));
$view->addExtension(new \Twig\Extension\DebugExtension());

// Register Eloquent single connection
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($cfg['settings']['db']['connections']['mysql']);
Expand Down
6 changes: 3 additions & 3 deletions src/RunTracy/Helpers/ConsolePanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ function blinker() {

public function getPanel()
{
$this->noLogin = $this->cfg['ConsoleNoLogin'];
$this->terminalJs = $this->cfg['ConsoleTerminalJs'];
$this->terminalCss = $this->cfg['ConsoleTerminalCss'];
$this->noLogin = isset($this->cfg['ConsoleNoLogin']) ? $this->cfg['ConsoleNoLogin'] : null;
$this->terminalJs = isset($this->cfg['ConsoleTerminalJs']) ? $this->cfg['ConsoleTerminalJs'] : null;
$this->terminalCss = isset($this->cfg['ConsoleTerminalCss']) ? $this->cfg['ConsoleTerminalCss'] : null;

ob_start();
require __DIR__ .'../../Templates/ConsolePanel.phtml';
Expand Down
8 changes: 7 additions & 1 deletion src/RunTracy/Helpers/TwigPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ class TwigPanel implements IBarPanel
public function __construct($data = null)
{
$this->data = $data;
$this->dumper = new \Twig_Profiler_Dumper_Html();

if (class_exists('\Twig_Profiler_Dumper_Html', false)) {
$dumper = new \Twig_Profiler_Dumper_Html();
} else {
$dumper = new \Twig\Profiler\Dumper\HtmlDumper();
}
$this->dumper = $dumper;
}

public function getTab()
Expand Down
30 changes: 26 additions & 4 deletions tests/RunTracy/Helpers/TwigPanelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ public function testTwigPanel()
$c = $app->getContainer();

$c['twig_profile'] = function () {
return new \Twig_Profiler_Profile();
if (class_exists('\Twig_Profiler_Profile', false)) {
$profile = new \Twig_Profiler_Profile();
} else {
$profile = new \Twig\Profiler\Profile();
}
return $profile;
};

$view = new \Slim\Views\Twig(
Expand All @@ -42,14 +47,31 @@ public function testTwigPanel()
);
// Add extensions
$view->addExtension(new \Slim\Views\TwigExtension($c->get('router'), $c->get('request')->getUri()));
$view->addExtension(new \Twig_Extension_Profiler($c['twig_profile']));
$view->addExtension(new \Twig_Extension_Debug());

if (class_exists('\Twig_Extension_Profiler', false)) {
$profileExtention = new \Twig_Extension_Profiler($c['twig_profile']);
} else {
$profileExtention = new \Twig\Extension\ProfilerExtension($c['twig_profile']);
}
$view->addExtension($profileExtention);

if (class_exists('\Twig_Extension_Debug', false)) {
$debugExtention = new \Twig_Extension_Debug();
} else {
$debugExtention = new \Twig\Extension\DebugExtension();
}
$view->addExtension($debugExtention);

$this->assertInstanceOf('\Slim\App', $app);
$this->assertInstanceOf('\Slim\Container', $c);
$this->assertInstanceOf('\Twig_Profiler_Profile', $c['twig_profile']);
$this->assertInstanceOf('\Slim\Views\Twig', $view);

if (class_exists('\Twig_Profiler_Profile', false)) {
$this->assertInstanceOf('\Twig_Profiler_Profile', $c['twig_profile']);
} else {
$this->assertInstanceOf('\Twig\Extension\ProfilerExtension', $c['twig_profile']);
}

$panel = new \RunTracy\Helpers\TwigPanel($c['twig_profile']);

$this->assertInstanceOf('\Tracy\IBarPanel', $panel);
Expand Down