Commit 073b57a5 authored by Tomáš Pospíšil's avatar Tomáš Pospíšil
Browse files

VARIOUS FIXIES

parent 894f4017
......@@ -16,6 +16,7 @@
},
"require": {
"php": "^7.1",
"noximo/dbgr": "^0.1.5",
"tracy/tracy": "^2.7",
"nette/utils": "^3.0",
"smarty/smarty": "^3.1"
......
<?php
declare(strict_types=1);
namespace Praguebest\BarPanel;
use Praguebest\Tools;
......
<?php
declare(strict_types=1);
namespace Praguebest\BarPanel;
use Nette\Utils\Strings;
use Tracy\Helpers;
class Helper
final class Helper
{
private static $genericClasses = [
'Db',
......@@ -15,6 +17,8 @@ class Helper
'EPObject',
'EPModel',
'EPBase',
self::class,
\Praguebest\Tools\DBProfiler::class,
];
public static function getInternalSmartyBacktrace(array $backtraces = null): array
......@@ -37,9 +41,9 @@ class Helper
}
$lines = [];
$first = null;
for ($i = 0, $iMax = count($backtraces); $i < $iMax; $i++) {
foreach ($backtraces as $i => $iValue) {
$isGeneric = false;
$backtrace = $backtraces[$i];
$backtrace = $iValue;
$nextBacktrace = $backtrace;
if (array_key_exists($i + 1, $backtraces)) {
$nextBacktrace = $backtraces[$i + 1];
......@@ -66,7 +70,9 @@ class Helper
$first = $line;
}
$lines[] = $line;
if ($isGeneric === false) {
$lines[] = $line;
}
}
if ($first === null) {
......
<?php
declare(strict_types=1);
namespace Praguebest\BarPanel;
use Praguebest\Tools\OnOffSwitcher;
......
<?php
declare(strict_types=1);
namespace Praguebest\BarPanel;
use Nette\Utils\FileSystem;
......
<?php
declare(strict_types=1);
namespace Praguebest\BarPanel;
use Praguebest\Tools\OnOffSwitcher;
......
<?php
declare(strict_types=1);
namespace Praguebest\BarPanel;
use Praguebest\Tools\WebSwitcherUrls;
......
<?php
declare(strict_types=1);
namespace Praguebest\Tools;
class OnOffSwitcher
final class OnOffSwitcher
{
private const PREFIX = 'OnOffSwitcher-';
public static function shouldProfile(string $profileName): bool
{
if (session_status() === PHP_SESSION_NONE && !headers_sent()) {
......@@ -26,13 +30,13 @@ class OnOffSwitcher
private static function getFromSession(string $profileName): bool
{
$profileDB = $_SESSION[$profileName] ?? false;
$profileValue = $_SESSION[self::PREFIX . $profileName] ?? false;
return (bool)$profileDB;
return (bool)$profileValue;
}
private static function setToSession(string $profileName, bool $value): void
{
$_SESSION[$profileName] = $value;
$_SESSION[self::PREFIX . $profileName] = $value;
}
}
......@@ -4,6 +4,7 @@ namespace Praguebest\Tools;
use Praguebest\BarPanel\Registrator;
use Smarty;
use Smarty_Internal_Template;
class TraceableSmarty extends Smarty
{
......@@ -15,7 +16,7 @@ class TraceableSmarty extends Smarty
private $generatedTemplates = [];
private $collectVariables = false;
private $collectBacktraces = false;
private $collectBacktraces;
/**
* TraceableSmarty constructor.
......@@ -29,6 +30,13 @@ class TraceableSmarty extends Smarty
$this->collectVariables = true;
}
if (class_exists(\noximo\Dbgr::class)) {
$this->templatesSys->registerClass('Dbgr', \noximo\Dbgr::class);
}
if (class_exists(\Nette\Utils\Strings::class)) {
$this->templatesSys->registerClass('Strings', \Nette\Utils\Strings::class);
}
$this->collectBacktraces = OnOffSwitcher::shouldProfile(TraceableSmarty::SMARTY_VARIABLES);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment