Skip to content

Commit 2f666e6

Browse files
committed
ConnectionPanel: convert templates to Latte-like syntax
1 parent 17be844 commit 2f666e6

File tree

7 files changed

+189
-94
lines changed

7 files changed

+189
-94
lines changed

src/Bridges/DITracy/ContainerPanel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getTab(): string
4040
{
4141
return Nette\Utils\Helpers::capture(function () {
4242
$elapsedTime = $this->elapsedTime;
43-
require __DIR__ . '/templates/ContainerPanel.tab.phtml';
43+
require __DIR__ . '/dist/tab.phtml';
4444
});
4545
}
4646

@@ -76,7 +76,7 @@ public function getPanel(): string
7676
$parameters = $rc->getMethod('getStaticParameters')->getDeclaringClass()->getName() === Container::class
7777
? null
7878
: $container->getParameters();
79-
require __DIR__ . '/templates/ContainerPanel.panel.phtml';
79+
require __DIR__ . '/dist/panel.phtml';
8080
});
8181
}
8282
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
declare(strict_types=1);
3+
?>
4+
<?php use Tracy\Dumper ?>
5+
<style class="tracy-debug">
6+
#tracy-debug .nette-ContainerPanel table {
7+
width: 100%;
8+
white-space: nowrap;
9+
}
10+
11+
#tracy-debug .nette-ContainerPanel .created {
12+
font-weight: bold;
13+
}
14+
15+
#tracy-debug .nette-ContainerPanel .yes {
16+
color: green;
17+
font-weight: bold;
18+
}
19+
20+
#tracy-debug .nette-ContainerPanel table pre {
21+
display: inline;
22+
background: transparent;
23+
padding: 0;
24+
word-break: normal;
25+
}
26+
</style>
27+
28+
<h1>Nette DI Container</h1>
29+
30+
<div class="tracy-inner nette-ContainerPanel">
31+
<div class="tracy-inner-container">
32+
<p>Source: <?= Tracy\Helpers::editorLink($file) ?>
33+
</p>
34+
35+
<table class="tracy-sortable">
36+
<thead>
37+
<tr>
38+
<th>Name</th>
39+
<th>Autowired</th>
40+
<th>Service</th>
41+
<th>Tags</th>
42+
</tr>
43+
</thead>
44+
<tbody>
45+
<?php foreach ($services as $name => $type): ?><?php $name = (string) $name ?><?php $autowired = in_array($name, array_merge($wiring[$type][0] ?? [], $wiring[$type][1] ?? []), strict: true) ?> <tr>
46+
<td class="<?= Tracy\Helpers::escapeHtml(isset($instances[$name]) ? 'created' : '') ?>
47+
">
48+
<?php if (is_numeric($name)): ?>
49+
<small><?= Tracy\Helpers::escapeHtml($name) ?>
50+
</small><?php else: ?>
51+
<?= Tracy\Helpers::escapeHtml($name) ?>
52+
53+
<?php endif ?>
54+
</td>
55+
<td class="<?= Tracy\Helpers::escapeHtml($autowired ? 'yes' : '') ?>
56+
">
57+
<?= Tracy\Helpers::escapeHtml($autowired ? 'yes' : (isset($wiring[$type]) ? 'no' : '?')) ?>
58+
59+
</td>
60+
<td>
61+
<?php if (isset($instances[$name]) && !$instances[$name] instanceof Nette\DI\Container): ?> <?= Dumper::toHtml($instances[$name], [Dumper::COLLAPSE => true, Dumper::LIVE => true, Dumper::DEPTH => 5]) ?>
62+
63+
<?php elseif (isset($instances[$name])): ?> <code><?= Tracy\Helpers::escapeHtml(get_class($instances[$name])) ?>
64+
</code>
65+
<?php elseif (is_string($type)): ?> <code><?= Tracy\Helpers::escapeHtml($type) ?>
66+
</code>
67+
<?php endif ?> </td>
68+
<td>
69+
<?php if (!isset($tags[$name])): ?><?php elseif (count($tags[$name]) === 1): ?> <?= Tracy\Helpers::escapeHtml(key($tags[$name])) ?>
70+
 = <?= Dumper::toHtml(current($tags[$name]), [Dumper::COLLAPSE => true]) ?>
71+
72+
<?php else: ?> <?= Dumper::toHtml($tags[$name], [Dumper::COLLAPSE => true]) ?>
73+
74+
<?php endif ?> </td>
75+
</tr>
76+
<?php endforeach ?> </tbody>
77+
</table>
78+
79+
<h2>Parameters</h2>
80+
81+
<div class="nette-ContainerPanel-parameters">
82+
<?php if ($parameters === null): ?> <i>disabled via 'di › export › parameters'</i>
83+
<?php else: ?> <?= Dumper::toHtml($parameters) ?>
84+
85+
<?php endif ?> </div>
86+
</div>
87+
</div>

src/Bridges/DITracy/dist/tab.phtml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
declare(strict_types=1);
3+
?>
4+
<span title="Nette DI Container">
5+
<svg viewBox="0 0 2048 2048">
6+
<path fill="#ae7c21" d="m1675 690.55v-125c0-36-4-60-13-71-9-12-26-18-52-18s-43 6-52 17c-8 11-12 36-12 72v910.62c0 37 4 61 12 72 9 11 26 17 52 17s44-6 52-17c9-12 13-36 13-72v-207h243v165c0 86-4 148-12 187-8 38-21 70-39 96-20 28-45 48-77 59-31 11-87 16-170 16-96 0-161-5-196-16-34-11-63-31-86-59-21-26-36-59-45-97-9-39-14-101-14-186v-826.62c0-85 4-147 13-185s25-71 46-97c23-29 54-49 92-60s102-17 189-17c75 0 130 6 164 17s61 30 81 59c19 26 33 59 41 99 8 39 12 101 12 185v84zm-524 1086.6h-254v-1514.6h254zm-1025 0v-1514.6h316c127 0 212 27 257 81 44 53 66 159 66 316v721.62c0 157-22 263-66 317-44 53-130 80-257 80zm388-314v-884.62c0-35-4-58-13-70-9-11-26-17-53-17h-66v1058.6h66c26 0 44-6 53-17 9-12 14-35 14-70z"/>
7+
</svg
8+
><span class="tracy-label"><?= Tracy\Helpers::escapeHtml($elapsedTime ? sprintf('%0.1f ms', $elapsedTime * 1000) : '') ?>
9+
</span>
10+
</span>

src/Bridges/DITracy/panel.latte

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{use Tracy\Dumper}
2+
3+
<style class="tracy-debug">
4+
#tracy-debug .nette-ContainerPanel table {
5+
width: 100%;
6+
white-space: nowrap;
7+
}
8+
9+
#tracy-debug .nette-ContainerPanel .created {
10+
font-weight: bold;
11+
}
12+
13+
#tracy-debug .nette-ContainerPanel .yes {
14+
color: green;
15+
font-weight: bold;
16+
}
17+
18+
#tracy-debug .nette-ContainerPanel table pre {
19+
display: inline;
20+
background: transparent;
21+
padding: 0;
22+
word-break: normal;
23+
}
24+
</style>
25+
26+
<h1>Nette DI Container</h1>
27+
28+
<div class="tracy-inner nette-ContainerPanel">
29+
<div class="tracy-inner-container">
30+
<p>Source: {Tracy\Helpers::editorLink($file)}</p>
31+
32+
<table class="tracy-sortable">
33+
<thead>
34+
<tr>
35+
<th>Name</th>
36+
<th>Autowired</th>
37+
<th>Service</th>
38+
<th>Tags</th>
39+
</tr>
40+
</thead>
41+
<tbody>
42+
{foreach $services as $name => $type}
43+
{do $name = (string) $name}
44+
{do $autowired = in_array($name, array_merge($wiring[$type][0] ?? [], $wiring[$type][1] ?? []), strict: true)}
45+
<tr>
46+
<td class="{isset($instances[$name]) ? created : ''}">
47+
{if is_numeric($name)}<small>{$name}</small>{else}{$name}{/if}
48+
</td>
49+
<td class="{$autowired ? yes : ''}">
50+
{$autowired ? yes : (isset($wiring[$type]) ? no : '?')}
51+
</td>
52+
<td>
53+
{if isset($instances[$name]) && !$instances[$name] instanceof Nette\DI\Container}
54+
{Dumper::toHtml($instances[$name], [Dumper::COLLAPSE => true, Dumper::LIVE => true, Dumper::DEPTH => 5])}
55+
{elseif isset($instances[$name])}
56+
<code>{get_class($instances[$name])}</code>
57+
{elseif is_string($type)}
58+
<code>{$type}</code>
59+
{/if}
60+
</td>
61+
<td>
62+
{if !isset($tags[$name])}
63+
{elseif count($tags[$name]) === 1}
64+
{key($tags[$name])} = {Dumper::toHtml(current($tags[$name]), [Dumper::COLLAPSE => true])}
65+
{else}
66+
{Dumper::toHtml($tags[$name], [Dumper::COLLAPSE => true])}
67+
{/if}
68+
</td>
69+
</tr>
70+
{/foreach}
71+
</tbody>
72+
</table>
73+
74+
<h2>Parameters</h2>
75+
76+
<div class="nette-ContainerPanel-parameters">
77+
{if $parameters === null}
78+
<i>disabled via 'di › export › parameters'</i>
79+
{else}
80+
{Dumper::toHtml($parameters)}
81+
{/if}
82+
</div>
83+
</div>
84+
</div>

src/Bridges/DITracy/tab.latte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<span title="Nette DI Container">
2+
<svg viewBox="0 0 2048 2048">
3+
<path fill="#ae7c21" d="m1675 690.55v-125c0-36-4-60-13-71-9-12-26-18-52-18s-43 6-52 17c-8 11-12 36-12 72v910.62c0 37 4 61 12 72 9 11 26 17 52 17s44-6 52-17c9-12 13-36 13-72v-207h243v165c0 86-4 148-12 187-8 38-21 70-39 96-20 28-45 48-77 59-31 11-87 16-170 16-96 0-161-5-196-16-34-11-63-31-86-59-21-26-36-59-45-97-9-39-14-101-14-186v-826.62c0-85 4-147 13-185s25-71 46-97c23-29 54-49 92-60s102-17 189-17c75 0 130 6 164 17s61 30 81 59c19 26 33 59 41 99 8 39 12 101 12 185v84zm-524 1086.6h-254v-1514.6h254zm-1025 0v-1514.6h316c127 0 212 27 257 81 44 53 66 159 66 316v721.62c0 157-22 263-66 317-44 53-130 80-257 80zm388-314v-884.62c0-35-4-58-13-70-9-11-26-17-53-17h-66v1058.6h66c26 0 44-6 53-17 9-12 14-35 14-70z"/>
4+
</svg
5+
><span class="tracy-label">{$elapsedTime ? sprintf('%0.1f ms', $elapsedTime * 1000) : ''}</span>
6+
</span>

src/Bridges/DITracy/templates/ContainerPanel.panel.phtml

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/Bridges/DITracy/templates/ContainerPanel.tab.phtml

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)