clock-work
This commit is contained in:
18
vendor/barryvdh/laravel-debugbar/composer.json
vendored
18
vendor/barryvdh/laravel-debugbar/composer.json
vendored
@@ -10,17 +10,17 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"php": "^8.0",
|
||||
"maximebf/debugbar": "^1.17.2",
|
||||
"illuminate/routing": "^7|^8|^9",
|
||||
"illuminate/session": "^7|^8|^9",
|
||||
"illuminate/support": "^7|^8|^9",
|
||||
"symfony/finder": "^5|^6"
|
||||
"illuminate/routing": "^9|^10",
|
||||
"illuminate/session": "^9|^10",
|
||||
"illuminate/support": "^9|^10",
|
||||
"symfony/finder": "^6"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.3.3",
|
||||
"orchestra/testbench-dusk": "^5|^6|^7",
|
||||
"phpunit/phpunit": "^8.5|^9.0",
|
||||
"orchestra/testbench-dusk": "^5|^6|^7|^8",
|
||||
"phpunit/phpunit": "^8.5.30|^9.0",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"autoload": {
|
||||
@@ -52,8 +52,8 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"check-style": "phpcs -p --standard=PSR12 config/ src/ tests/",
|
||||
"fix-style": "phpcbf -p --standard=PSR12 config/ src/ tests/",
|
||||
"check-style": "phpcs -p --standard=PSR12 config/ src/ tests/ --ignore=src/Resources/* ",
|
||||
"fix-style": "phpcbf -p --standard=PSR12 config/ src/ tests/ --ignore=src/Resources*",
|
||||
"test": "phpunit"
|
||||
}
|
||||
}
|
||||
|
@@ -92,7 +92,7 @@ return [
|
||||
| Vendor files are included by default, but can be set to false.
|
||||
| This can also be set to 'js' or 'css', to only include javascript or css vendor files.
|
||||
| Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
|
||||
| and for js: jquery and and highlight.js
|
||||
| and for js: jquery and highlight.js
|
||||
| So if you want syntax highlighting, set it to true.
|
||||
| jQuery is set to not conflict with existing jQuery scripts.
|
||||
|
|
||||
@@ -198,7 +198,8 @@ return [
|
||||
'types' => ['SELECT'], // Deprecated setting, is always only SELECT
|
||||
],
|
||||
'hints' => false, // Show hints for common mistakes
|
||||
'show_copy' => false, // Show copy button next to the query
|
||||
'show_copy' => false, // Show copy button next to the query,
|
||||
'slow_threshold' => false, // Only track queries that last longer than this time in ms
|
||||
],
|
||||
'mail' => [
|
||||
'full_log' => false,
|
||||
@@ -206,6 +207,7 @@ return [
|
||||
'views' => [
|
||||
'timeline' => false, // Add the views to the timeline (Experimental)
|
||||
'data' => false, //Note: Can slow down the application, because the data can be quite large..
|
||||
'exclude_paths' => [], // Add the paths which you don't want to appear in the views
|
||||
],
|
||||
'route' => [
|
||||
'label' => true, // show complete route on bar
|
||||
|
2
vendor/barryvdh/laravel-debugbar/readme.md
vendored
2
vendor/barryvdh/laravel-debugbar/readme.md
vendored
@@ -1,4 +1,4 @@
|
||||
## Laravel Debugbar
|
||||
## Debugbar for Laravel
|
||||

|
||||
[](http://choosealicense.com/licenses/mit/)
|
||||
[](https://packagist.org/packages/barryvdh/laravel-debugbar)
|
||||
|
@@ -134,7 +134,7 @@ class QueryCollector extends PDOCollector
|
||||
$pdo = null;
|
||||
try {
|
||||
$pdo = $connection->getPdo();
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
// ignore error for non-pdo laravel drivers
|
||||
}
|
||||
$bindings = $connection->prepareBindings($bindings);
|
||||
@@ -511,6 +511,41 @@ class QueryCollector extends PDOCollector
|
||||
'type' => 'explain',
|
||||
];
|
||||
}
|
||||
} elseif ($query['driver'] === 'sqlite') {
|
||||
$vmi = '<table style="margin:-5px -11px !important;width: 100% !important">';
|
||||
$vmi .= "<thead><tr>
|
||||
<td>Address</td>
|
||||
<td>Opcode</td>
|
||||
<td>P1</td>
|
||||
<td>P2</td>
|
||||
<td>P3</td>
|
||||
<td>P4</td>
|
||||
<td>P5</td>
|
||||
<td>Comment</td>
|
||||
</tr></thead>";
|
||||
|
||||
foreach ($query['explain'] as $explain) {
|
||||
$vmi .= "<tr>
|
||||
<td>{$explain->addr}</td>
|
||||
<td>{$explain->opcode}</td>
|
||||
<td>{$explain->p1}</td>
|
||||
<td>{$explain->p2}</td>
|
||||
<td>{$explain->p3}</td>
|
||||
<td>{$explain->p4}</td>
|
||||
<td>{$explain->p5}</td>
|
||||
<td>{$explain->comment}</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
$vmi .= '</table>';
|
||||
|
||||
$statements[] = [
|
||||
'sql' => " - EXPLAIN:",
|
||||
'type' => 'explain',
|
||||
'params' => [
|
||||
'Virtual Machine Instructions' => $vmi,
|
||||
]
|
||||
];
|
||||
} else {
|
||||
foreach ($query['explain'] as $explain) {
|
||||
$statements[] = [
|
||||
|
@@ -5,24 +5,51 @@ namespace Barryvdh\Debugbar\DataCollector;
|
||||
use Barryvdh\Debugbar\DataFormatter\SimpleFormatter;
|
||||
use DebugBar\Bridge\Twig\TwigCollector;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class ViewCollector extends TwigCollector
|
||||
{
|
||||
protected $name;
|
||||
protected $templates = [];
|
||||
protected $collect_data;
|
||||
protected $exclude_paths;
|
||||
|
||||
/**
|
||||
* A list of known editor strings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $editors = [
|
||||
'sublime' => 'subl://open?url=file://%file&line=%line',
|
||||
'textmate' => 'txmt://open?url=file://%file&line=%line',
|
||||
'emacs' => 'emacs://open?url=file://%file&line=%line',
|
||||
'macvim' => 'mvim://open/?url=file://%file&line=%line',
|
||||
'phpstorm' => 'phpstorm://open?file=%file&line=%line',
|
||||
'idea' => 'idea://open?file=%file&line=%line',
|
||||
'vscode' => 'vscode://file/%file:%line',
|
||||
'vscode-insiders' => 'vscode-insiders://file/%file:%line',
|
||||
'vscode-remote' => 'vscode://vscode-remote/%file:%line',
|
||||
'vscode-insiders-remote' => 'vscode-insiders://vscode-remote/%file:%line',
|
||||
'vscodium' => 'vscodium://file/%file:%line',
|
||||
'nova' => 'nova://core/open/file?filename=%file&line=%line',
|
||||
'xdebug' => 'xdebug://%file@%line',
|
||||
'atom' => 'atom://core/open/file?filename=%file&line=%line',
|
||||
'espresso' => 'x-espresso://open?filepath=%file&lines=%line',
|
||||
'netbeans' => 'netbeans://open/?f=%file:%line',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a ViewCollector
|
||||
*
|
||||
* @param bool $collectData Collects view data when tru
|
||||
* @param string[] $excludePaths Paths to exclude from collection
|
||||
*/
|
||||
public function __construct($collectData = true)
|
||||
public function __construct($collectData = true, $excludePaths = [])
|
||||
{
|
||||
$this->setDataFormatter(new SimpleFormatter());
|
||||
$this->collect_data = $collectData;
|
||||
$this->name = 'views';
|
||||
$this->templates = [];
|
||||
$this->exclude_paths = $excludePaths;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
@@ -35,7 +62,7 @@ class ViewCollector extends TwigCollector
|
||||
return [
|
||||
'views' => [
|
||||
'icon' => 'leaf',
|
||||
'widget' => 'PhpDebugBar.Widgets.TemplatesWidget',
|
||||
'widget' => 'PhpDebugBar.Widgets.LaravelViewTemplatesWidget',
|
||||
'map' => 'views',
|
||||
'default' => '[]'
|
||||
],
|
||||
@@ -46,6 +73,36 @@ class ViewCollector extends TwigCollector
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the editor href for a given file and line, if available.
|
||||
*
|
||||
* @param string $filePath
|
||||
* @param int $line
|
||||
*
|
||||
* @throws InvalidArgumentException If editor resolver does not return a string
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
protected function getEditorHref($filePath, $line)
|
||||
{
|
||||
if (empty(config('debugbar.editor'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (empty($this->editors[config('debugbar.editor')])) {
|
||||
throw new InvalidArgumentException(
|
||||
'Unknown editor identifier: ' . config('debugbar.editor') . '. Known editors:' .
|
||||
implode(', ', array_keys($this->editors))
|
||||
);
|
||||
}
|
||||
|
||||
$filePath = $this->replaceSitesPath($filePath);
|
||||
|
||||
$url = str_replace(['%file', '%line'], [$filePath, $line], $this->editors[config('debugbar.editor')]);
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a View instance to the Collector
|
||||
*
|
||||
@@ -71,6 +128,12 @@ class ViewCollector extends TwigCollector
|
||||
$path = '';
|
||||
}
|
||||
|
||||
foreach ($this->exclude_paths as $excludePath) {
|
||||
if (strpos($path, $excludePath) !== false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->collect_data) {
|
||||
$params = array_keys($view->getData());
|
||||
} else {
|
||||
@@ -86,6 +149,7 @@ class ViewCollector extends TwigCollector
|
||||
'param_count' => count($params),
|
||||
'params' => $params,
|
||||
'type' => $type,
|
||||
'editorLink' => $this->getEditorHref($view->getPath(), 0),
|
||||
];
|
||||
|
||||
if ($this->getXdebugLink($path)) {
|
||||
@@ -104,4 +168,16 @@ class ViewCollector extends TwigCollector
|
||||
'templates' => $templates,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace remote path
|
||||
*
|
||||
* @param string $filePath
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function replaceSitesPath($filePath)
|
||||
{
|
||||
return str_replace(config('debugbar.remote_sites_path'), config('debugbar.local_sites_path'), $filePath);
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ namespace Barryvdh\Debugbar\DataFormatter;
|
||||
|
||||
use DebugBar\DataFormatter\DataFormatter;
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class QueryFormatter extends DataFormatter
|
||||
{
|
||||
/**
|
||||
|
@@ -9,6 +9,7 @@ use DebugBar\DataFormatter\DataFormatter;
|
||||
*
|
||||
* @see https://github.com/symfony/symfony/blob/v3.4.4/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class SimpleFormatter extends DataFormatter
|
||||
{
|
||||
/**
|
||||
|
@@ -23,6 +23,7 @@ class JavascriptRenderer extends BaseJavascriptRenderer
|
||||
$this->cssVendors['fontawesome'] = __DIR__ . '/Resources/vendor/font-awesome/style.css';
|
||||
$this->jsFiles['laravel-sql'] = __DIR__ . '/Resources/sqlqueries/widget.js';
|
||||
$this->jsFiles['laravel-cache'] = __DIR__ . '/Resources/cache/widget.js';
|
||||
$this->jsFiles['laravel-view'] = __DIR__ . '/Resources/templates/widget.js';
|
||||
|
||||
$theme = config('debugbar.theme', 'auto');
|
||||
switch ($theme) {
|
||||
|
@@ -34,6 +34,7 @@ use DebugBar\DebugBar;
|
||||
use DebugBar\Storage\PdoStorage;
|
||||
use DebugBar\Storage\RedisStorage;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -204,7 +205,8 @@ class LaravelDebugbar extends DebugBar
|
||||
if ($this->shouldCollect('views', true) && isset($this->app['events'])) {
|
||||
try {
|
||||
$collectData = $this->app['config']->get('debugbar.options.views.data', true);
|
||||
$this->addCollector(new ViewCollector($collectData));
|
||||
$excludePaths = $this->app['config']->get('debugbar.options.views.exclude_paths', []);
|
||||
$this->addCollector(new ViewCollector($collectData, $excludePaths));
|
||||
$this->app['events']->listen(
|
||||
'composing:*',
|
||||
function ($view, $data = []) use ($debugbar) {
|
||||
@@ -258,7 +260,7 @@ class LaravelDebugbar extends DebugBar
|
||||
try {
|
||||
$logMessage = (string) $message;
|
||||
if (mb_check_encoding($logMessage, 'UTF-8')) {
|
||||
$logMessage .= (!empty($context) ? ' ' . json_encode($context) : '');
|
||||
$logMessage .= (!empty($context) ? ' ' . json_encode($context, JSON_PRETTY_PRINT) : '');
|
||||
} else {
|
||||
$logMessage = "[INVALID UTF-8 DATA]";
|
||||
}
|
||||
@@ -635,7 +637,7 @@ class LaravelDebugbar extends DebugBar
|
||||
/**
|
||||
* Adds an exception to be profiled in the debug bar
|
||||
*
|
||||
* @param Exception $e
|
||||
* @param Throwable $e
|
||||
*/
|
||||
public function addThrowable($e)
|
||||
{
|
||||
|
@@ -24,6 +24,8 @@ div.phpdebugbar-openhandler,
|
||||
div.phpdebugbar div.phpdebugbar-header > div > *,
|
||||
div.phpdebugbar ul.phpdebugbar-widgets-timeline li span.phpdebugbar-widgets-label,
|
||||
div.phpdebugbar ul.phpdebugbar-widgets-timeline li span.phpdebugbar-widgets-collector,
|
||||
div.phpdebugbar ul.phpdebugbar-widgets-list li.phpdebugbar-widgets-list-item,
|
||||
div.phpdebugbar ul.phpdebugbar-widgets-list li span.phpdebugbar-widgets-label,
|
||||
div.phpdebugbar code.phpdebugbar-widgets-sql span.hljs-keyword,
|
||||
div.phpdebugbar-openhandler .phpdebugbar-openhandler-header,
|
||||
div.phpdebugbar-openhandler .phpdebugbar-openhandler-header a {
|
||||
|
@@ -13,6 +13,7 @@ div.phpdebugbar {
|
||||
|
||||
div.phpdebugbar * {
|
||||
direction: ltr;
|
||||
font-size: initial;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
98
vendor/barryvdh/laravel-debugbar/src/Resources/templates/widget.js
vendored
Normal file
98
vendor/barryvdh/laravel-debugbar/src/Resources/templates/widget.js
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
(function($) {
|
||||
|
||||
var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-');
|
||||
|
||||
/**
|
||||
* Widget for the displaying templates data
|
||||
*
|
||||
* Options:
|
||||
* - data
|
||||
*/
|
||||
var TemplatesWidget = PhpDebugBar.Widgets.LaravelViewTemplatesWidget = PhpDebugBar.Widget.extend({
|
||||
|
||||
className: csscls('templates'),
|
||||
|
||||
render: function() {
|
||||
this.$status = $('<div />').addClass(csscls('status')).appendTo(this.$el);
|
||||
|
||||
this.$list = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, tpl) {
|
||||
$('<span />').addClass(csscls('name')).text(tpl.name).appendTo(li);
|
||||
|
||||
if (typeof tpl.editorLink !== 'undefined' && tpl.editorLink !== null) {
|
||||
$('<a href="' + tpl.editorLink + '"></a>')
|
||||
.addClass(csscls('editor-link'))
|
||||
.on('click', function (event) {
|
||||
event.stopPropagation();
|
||||
})
|
||||
.appendTo(li);
|
||||
}
|
||||
if (typeof tpl.xdebug_link !== 'undefined' && tpl.xdebug_link !== null) {
|
||||
if (tpl.xdebug_link.ajax) {
|
||||
$('<a title="' + tpl.xdebug_link.url + '"></a>').on('click', function () {
|
||||
$.ajax(tpl.xdebug_link.url);
|
||||
}).addClass(csscls('editor-link')).appendTo(li);
|
||||
} else {
|
||||
$('<a href="' + tpl.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(li);
|
||||
}
|
||||
}
|
||||
if (tpl.render_time_str) {
|
||||
$('<span title="Render time" />').addClass(csscls('render-time')).text(tpl.render_time_str).appendTo(li);
|
||||
}
|
||||
if (tpl.memory_str) {
|
||||
$('<span title="Memory usage" />').addClass(csscls('memory')).text(tpl.memory_str).appendTo(li);
|
||||
}
|
||||
if (typeof(tpl.param_count) != 'undefined') {
|
||||
$('<span title="Parameter count" />').addClass(csscls('param-count')).text(tpl.param_count).appendTo(li);
|
||||
}
|
||||
if (typeof(tpl.type) != 'undefined' && tpl.type) {
|
||||
$('<span title="Type" />').addClass(csscls('type')).text(tpl.type).appendTo(li);
|
||||
}
|
||||
if (tpl.params && !$.isEmptyObject(tpl.params)) {
|
||||
var table = $('<table><tr><th colspan="2">Params</th></tr></table>').addClass(csscls('params')).appendTo(li);
|
||||
for (var key in tpl.params) {
|
||||
if (typeof tpl.params[key] !== 'function') {
|
||||
table.append('<tr><td class="' + csscls('name') + '">' + key + '</td><td class="' + csscls('value') +
|
||||
'"><pre><code>' + tpl.params[key] + '</code></pre></td></tr>');
|
||||
}
|
||||
}
|
||||
li.css('cursor', 'pointer').click(function() {
|
||||
if (table.is(':visible')) {
|
||||
table.hide();
|
||||
} else {
|
||||
table.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}});
|
||||
this.$list.$el.appendTo(this.$el);
|
||||
this.$callgraph = $('<div />').addClass(csscls('callgraph')).appendTo(this.$el);
|
||||
|
||||
this.bindAttr('data', function(data) {
|
||||
this.$list.set('data', data.templates);
|
||||
this.$status.empty();
|
||||
this.$callgraph.empty();
|
||||
|
||||
var sentence = data.sentence || "templates were rendered";
|
||||
$('<span />').text(data.nb_templates + " " + sentence).appendTo(this.$status);
|
||||
|
||||
if (data.accumulated_render_time_str) {
|
||||
this.$status.append($('<span title="Accumulated render time" />').addClass(csscls('render-time')).text(data.accumulated_render_time_str));
|
||||
}
|
||||
if (data.memory_usage_str) {
|
||||
this.$status.append($('<span title="Memory usage" />').addClass(csscls('memory')).text(data.memory_usage_str));
|
||||
}
|
||||
if (data.nb_blocks > 0) {
|
||||
$('<div />').text(data.nb_blocks + " blocks were rendered").appendTo(this.$status);
|
||||
}
|
||||
if (data.nb_macros > 0) {
|
||||
$('<div />').text(data.nb_macros + " macros were rendered").appendTo(this.$status);
|
||||
}
|
||||
if (typeof data.callgraph !== 'undefined') {
|
||||
this.$callgraph.html(data.callgraph);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(PhpDebugBar.$);
|
@@ -10,7 +10,7 @@ use Twig_SimpleFunction;
|
||||
/**
|
||||
* Access Laravels auth class in your Twig templates.
|
||||
*/
|
||||
class Debug extends Twig_Extension
|
||||
class Debug extends Extension
|
||||
{
|
||||
/**
|
||||
* @var \Barryvdh\Debugbar\LaravelDebugbar
|
||||
@@ -44,8 +44,15 @@ class Debug extends Twig_Extension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
// Maintain compatibility with Twig 2 and 3.
|
||||
$simpleFunction = 'Twig_SimpleFunction';
|
||||
|
||||
if (!class_exists($simpleFunction)) {
|
||||
$simpleFunction = '\Twig\TwigFunction';
|
||||
}
|
||||
|
||||
return [
|
||||
new Twig_SimpleFunction(
|
||||
new $simpleFunction(
|
||||
'debug',
|
||||
[$this, 'debug'],
|
||||
['needs_context' => true, 'needs_environment' => true]
|
||||
@@ -57,10 +64,10 @@ class Debug extends Twig_Extension
|
||||
* Based on Twig_Extension_Debug / twig_var_dump
|
||||
* (c) 2011 Fabien Potencier
|
||||
*
|
||||
* @param Twig_Environment $env
|
||||
* @param \Twig_Environment|\Twig\Environment $env
|
||||
* @param $context
|
||||
*/
|
||||
public function debug(Twig_Environment $env, $context)
|
||||
public function debug($env, $context)
|
||||
{
|
||||
if (!$env->isDebug() || !$this->debugbar) {
|
||||
return;
|
||||
|
@@ -3,14 +3,11 @@
|
||||
namespace Barryvdh\Debugbar\Twig\Extension;
|
||||
|
||||
use DebugBar\DataFormatter\DataFormatterInterface;
|
||||
use Twig_Environment;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
* Dump variables using the DataFormatter
|
||||
*/
|
||||
class Dump extends Twig_Extension
|
||||
class Dump extends Extension
|
||||
{
|
||||
/**
|
||||
* @var \DebugBar\DataFormatter\DataFormatter
|
||||
@@ -40,8 +37,15 @@ class Dump extends Twig_Extension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
// Maintain compatibility with Twig 2 and 3.
|
||||
$simpleFunction = '\Twig_SimpleFunction';
|
||||
|
||||
if (!class_exists($simpleFunction)) {
|
||||
$simpleFunction = '\Twig\TwigFunction';
|
||||
}
|
||||
|
||||
return [
|
||||
new Twig_SimpleFunction(
|
||||
new $simpleFunction(
|
||||
'dump',
|
||||
[$this, 'dump'],
|
||||
['is_safe' => ['html'], 'needs_context' => true, 'needs_environment' => true]
|
||||
@@ -53,12 +57,12 @@ class Dump extends Twig_Extension
|
||||
* Based on Twig_Extension_Debug / twig_var_dump
|
||||
* (c) 2011 Fabien Potencier
|
||||
*
|
||||
* @param Twig_Environment $env
|
||||
* @param \Twig_Environment|\Twig\Environment $env
|
||||
* @param $context
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dump(Twig_Environment $env, $context)
|
||||
public function dump($env, $context)
|
||||
{
|
||||
$output = '';
|
||||
|
||||
|
14
vendor/barryvdh/laravel-debugbar/src/Twig/Extension/Extension.php
vendored
Normal file
14
vendor/barryvdh/laravel-debugbar/src/Twig/Extension/Extension.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Twig\Extension;
|
||||
|
||||
// Maintain compatibility with Twig 2 and 3.
|
||||
if (class_exists('\Twig_Extension')) {
|
||||
abstract class Extension extends \Twig_Extension
|
||||
{
|
||||
}
|
||||
} else {
|
||||
abstract class Extension extends \Twig\Extension\AbstractExtension
|
||||
{
|
||||
}
|
||||
}
|
@@ -4,13 +4,12 @@ namespace Barryvdh\Debugbar\Twig\Extension;
|
||||
|
||||
use Barryvdh\Debugbar\Twig\TokenParser\StopwatchTokenParser;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Twig_Extension;
|
||||
|
||||
/**
|
||||
* Access Laravels auth class in your Twig templates.
|
||||
* Based on Symfony\Bridge\Twig\Extension\StopwatchExtension
|
||||
*/
|
||||
class Stopwatch extends Twig_Extension
|
||||
class Stopwatch extends Extension
|
||||
{
|
||||
/**
|
||||
* @var \Barryvdh\Debugbar\LaravelDebugbar
|
||||
|
14
vendor/barryvdh/laravel-debugbar/src/Twig/Node/Node.php
vendored
Normal file
14
vendor/barryvdh/laravel-debugbar/src/Twig/Node/Node.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Twig\Node;
|
||||
|
||||
// Maintain compatibility with Twig 2 and 3.
|
||||
if (class_exists('\Twig_Node')) {
|
||||
abstract class Node extends \Twig_Node
|
||||
{
|
||||
}
|
||||
} else {
|
||||
abstract class Node extends \Twig\Node\Node
|
||||
{
|
||||
}
|
||||
}
|
@@ -7,20 +7,37 @@ namespace Barryvdh\Debugbar\Twig\Node;
|
||||
*
|
||||
* @author Wouter J <wouter@wouterj.nl>
|
||||
*/
|
||||
class StopwatchNode extends \Twig_Node
|
||||
class StopwatchNode extends Node
|
||||
{
|
||||
/**
|
||||
* @param \Twig_NodeInterface|\Twig\Node\Node $name
|
||||
* @param $body
|
||||
* @param \Twig_Node_Expression_AssignName|\Twig\Node\Expression\AssignNameExpression $var
|
||||
* @param $lineno
|
||||
* @param $tag
|
||||
*/
|
||||
public function __construct(
|
||||
\Twig_NodeInterface $name,
|
||||
$name,
|
||||
$body,
|
||||
\Twig_Node_Expression_AssignName $var,
|
||||
$var,
|
||||
$lineno = 0,
|
||||
$tag = null
|
||||
) {
|
||||
parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(\Twig_Compiler $compiler)
|
||||
/**
|
||||
* @param \Twig_Compiler|\Twig\Compiler $env
|
||||
* @return void
|
||||
*/
|
||||
public function compile($compiler)
|
||||
{
|
||||
// Maintain compatibility with Twig 2 and 3.
|
||||
$extension = \Barryvdh\Debugbar\Twig\Extension\Stopwatch::class;
|
||||
if (class_exists('\Twig_Node')) {
|
||||
$extension = 'stopwatch';
|
||||
}
|
||||
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write('')
|
||||
@@ -28,11 +45,11 @@ class StopwatchNode extends \Twig_Node
|
||||
->raw(' = ')
|
||||
->subcompile($this->getNode('name'))
|
||||
->write(";\n")
|
||||
->write("\$this->env->getExtension('stopwatch')->getDebugbar()->startMeasure(")
|
||||
->write(sprintf("\$this->env->getExtension('%s')->getDebugbar()->startMeasure(", $extension))
|
||||
->subcompile($this->getNode('var'))
|
||||
->raw(");\n")
|
||||
->subcompile($this->getNode('body'))
|
||||
->write("\$this->env->getExtension('stopwatch')->getDebugbar()->stopMeasure(")
|
||||
->write(sprintf("\$this->env->getExtension('%s')->getDebugbar()->stopMeasure(", $extension))
|
||||
->subcompile($this->getNode('var'))
|
||||
->raw(");\n");
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ use Barryvdh\Debugbar\Twig\Node\StopwatchNode;
|
||||
*
|
||||
* @author Wouter J <wouter@wouterj.nl>
|
||||
*/
|
||||
class StopwatchTokenParser extends \Twig_TokenParser
|
||||
class StopwatchTokenParser extends TokenParser
|
||||
{
|
||||
protected $debugbarAvailable;
|
||||
|
||||
@@ -18,7 +18,10 @@ class StopwatchTokenParser extends \Twig_TokenParser
|
||||
$this->debugbarAvailable = $debugbarAvailable;
|
||||
}
|
||||
|
||||
public function parse(\Twig_Token $token)
|
||||
/**
|
||||
* @param \Twig_Token|\Twig\Token $token
|
||||
*/
|
||||
public function parse($token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
@@ -26,17 +29,31 @@ class StopwatchTokenParser extends \Twig_TokenParser
|
||||
// {% stopwatch 'bar' %}
|
||||
$name = $this->parser->getExpressionParser()->parseExpression();
|
||||
|
||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||
// Maintain compatibility with Twig 2 and 3.
|
||||
if (class_exists("\Twig_Token")) {
|
||||
$blockEndType = \Twig_Token::BLOCK_END_TYPE;
|
||||
} else {
|
||||
$blockEndType = \Twig\Token::BLOCK_END_TYPE;
|
||||
}
|
||||
|
||||
$stream->expect($blockEndType);
|
||||
|
||||
// {% endstopwatch %}
|
||||
$body = $this->parser->subparse([$this, 'decideStopwatchEnd'], true);
|
||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect($blockEndType);
|
||||
|
||||
// Maintain compatibility with Twig 2 and 3.
|
||||
if (class_exists("\Twig_Node_Expression_AssignName")) {
|
||||
$assignNameExpression = new \Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine());
|
||||
} else {
|
||||
$assignNameExpression = new \Twig\Node\Expression\AssignNameExpression($this->parser->getVarName(), $token->getLine());
|
||||
}
|
||||
|
||||
if ($this->debugbarAvailable) {
|
||||
return new StopwatchNode(
|
||||
$name,
|
||||
$body,
|
||||
new \Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()),
|
||||
$assignNameExpression,
|
||||
$lineno,
|
||||
$this->getTag()
|
||||
);
|
||||
@@ -50,7 +67,10 @@ class StopwatchTokenParser extends \Twig_TokenParser
|
||||
return 'stopwatch';
|
||||
}
|
||||
|
||||
public function decideStopwatchEnd(\Twig_Token $token)
|
||||
/**
|
||||
* @param \Twig_Token|\Twig\Token $token
|
||||
*/
|
||||
public function decideStopwatchEnd($token)
|
||||
{
|
||||
return $token->test('endstopwatch');
|
||||
}
|
||||
|
14
vendor/barryvdh/laravel-debugbar/src/Twig/TokenParser/TokenParser.php
vendored
Normal file
14
vendor/barryvdh/laravel-debugbar/src/Twig/TokenParser/TokenParser.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Twig\TokenParser;
|
||||
|
||||
// Maintain compatibility with Twig 2 and 3.
|
||||
if (class_exists('\Twig_TokenParser')) {
|
||||
abstract class TokenParser extends \Twig_TokenParser
|
||||
{
|
||||
}
|
||||
} else {
|
||||
abstract class TokenParser extends \Twig\TokenParser\AbstractTokenParser
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user