-
Notifications
You must be signed in to change notification settings - Fork 5
Add symfony debug bar support #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
44372c3
initial working version
koertho 74fff50
add support for legacy templates, optimize output
koertho ef58391
run qa tools
koertho 6b30df4
fix tests
koertho e91f4dd
adjustment to debug bar and docs
koertho 5ca7ff7
add tests
koertho 6ecc4a2
fix review comments
koertho 358067a
adjust tests
koertho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
133 changes: 133 additions & 0 deletions
133
contao/templates/twig/data_collector/huh_encore.html.twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| {% extends '@WebProfiler/Profiler/layout.html.twig' %} | ||
|
|
||
| {% block toolbar %} | ||
|
|
||
| {% set icon %} | ||
| <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" | ||
| stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" | ||
| class="lucide lucide-waypoints-icon lucide-waypoints"><path d="m10.586 5.414-5.172 5.172"/><path | ||
| d="m18.586 13.414-5.172 5.172"/><path d="M6 12h12"/><circle cx="12" cy="20" r="2"/><circle | ||
| cx="12" cy="4" r="2"/><circle cx="20" cy="12" r="2"/><circle cx="4" cy="12" r="2"/></svg> | ||
| <span class="sf-toolbar-value">{{ collector.entries|length }}</span> | ||
| {% endset %} | ||
|
|
||
| {% set text %} | ||
| <div class="sf-toolbar-info-group"> | ||
| <div class="sf-toolbar-info-piece"> | ||
| <b>Enabled</b> | ||
| <span class="sf-toolbar-status sf-toolbar-status-{% if collector.enabled %}green{% else %}red{% endif %}">{{ collector.enabled ? 'yes' : 'no' }}</span> | ||
| </div> | ||
|
|
||
| <div class="sf-toolbar-info-piece"> | ||
| <b>Encore Entries</b> | ||
| <span class="sf-toolbar-status">{{ collector.entries|length }}</span> | ||
| </div> | ||
|
|
||
| <div class="sf-toolbar-info-piece"> | ||
| <b>Encore Extensions</b> | ||
| <span class="sf-toolbar-status">{{ collector.extensions|length }}</span> | ||
| </div> | ||
| </div> | ||
| <div class="sf-toolbar-info-group"> | ||
| <div class="sf-toolbar-info-piece"> | ||
| <b>Resources</b> | ||
| <span><a href="https://github.com/heimrichhannot/contao-encore-bundle" target="_blank" rel="help noreferrer noopener">Read the encore bundle docs</a></span> | ||
| </div> | ||
| </div> | ||
| {% endset %} | ||
|
|
||
| {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { | ||
| link: true, | ||
| additional_classes: (collector.enabled ? '' : 'sf-toolbar-status-red') } | ||
| ) }} | ||
|
|
||
| {% endblock %} | ||
|
|
||
| {% block menu %} | ||
| <span class="label"> | ||
| <span class="icon"> | ||
| <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" | ||
| stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" | ||
| class="lucide lucide-waypoints-icon lucide-waypoints"><path d="m10.586 5.414-5.172 5.172"/><path | ||
| d="m18.586 13.414-5.172 5.172"/><path d="M6 12h12"/><circle cx="12" cy="20" r="2"/><circle | ||
| cx="12" cy="4" r="2"/><circle cx="20" cy="12" r="2"/><circle cx="4" cy="12" r="2"/></svg> | ||
| </span> | ||
| <strong>Encore</strong> | ||
| </span> | ||
| {% endblock %} | ||
|
|
||
| {% block panel %} | ||
| <h2>Encore</h2> | ||
|
|
||
| <div class="metrics"> | ||
| <div class="metric"> | ||
| <span class="value status-{{ collector.enabled ? 'success' : 'danger' }}">{{ collector.enabled ? 'yes' : 'no' }}</span> | ||
| <span class="label">Enabled</span> | ||
| </div> | ||
|
|
||
| <div class="metric"> | ||
| <span class="value">{{ collector.version }}</span> | ||
| <span class="label">Encore Bundle version</span> | ||
| </div> | ||
|
|
||
| <div class="metric"> | ||
| <span class="value">{{ collector.extensions|length }}</span> | ||
| <span class="label">Registered extensions</span> | ||
| </div> | ||
|
|
||
| </div> | ||
|
|
||
|
|
||
| <h2>Page entry points</h2> | ||
|
|
||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th>Name</th> | ||
| <th>Active</th> | ||
| <th>Head</th> | ||
| <th>CSS</th> | ||
| <th>Origin</th> | ||
| <th>Extension</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
|
|
||
| {% for entry in collector.entries %} | ||
| <tr> | ||
| <td>{{ entry.name }}</td> | ||
| <td>{{ entry.active }}</td> | ||
| <td>{{ entry.head }}</td> | ||
| <td>{{ entry.requiresCss }}</td> | ||
| <td>{{ entry.origin }}</td> | ||
| <td>{{ entry.extension }}</td> | ||
| </tr> | ||
| {% endfor %} | ||
| </tbody> | ||
| </table> | ||
|
|
||
| <h2>Registered extensions</h2> | ||
|
|
||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th>Extension class</th> | ||
| <th>Entry Points</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {% for extension in collector.extensions %} | ||
| <tr> | ||
| <td>{{ extension.name }}</td> | ||
| <td> | ||
| <ul> | ||
| {% for entry in extension.entries %} | ||
| <li>{{ entry.name }}</li> | ||
| {% endfor %} | ||
| </ul> | ||
| </td> | ||
| </tr> | ||
| {% endfor %} | ||
| </tbody> | ||
| </table> | ||
| {% endblock %} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| <?php | ||
|
|
||
| namespace HeimrichHannot\EncoreBundle\DataCollector; | ||
|
|
||
| use Composer\InstalledVersions; | ||
| use HeimrichHannot\EncoreBundle\Collection\ExtensionCollection; | ||
| use HeimrichHannot\EncoreBundle\EntryPoint\EntryPoints; | ||
| use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector; | ||
| use Symfony\Component\HttpFoundation\Request; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| class EncoreCollector extends AbstractDataCollector | ||
| { | ||
| public function __construct( | ||
| private readonly ExtensionCollection $extensionCollection, | ||
| ) { | ||
| } | ||
|
|
||
| public function collect(Request $request, Response $response, ?\Throwable $exception = null): void | ||
| { | ||
| if ($request->attributes->has('encore_entries')) { | ||
| $entryPoints = $request->attributes->get('encore_entries'); | ||
| if (!($entryPoints instanceof EntryPoints)) { | ||
| $this->data['enabled'] = false; | ||
| } else { | ||
| $this->data['entries'] = $entryPoints->all(); | ||
| $this->data['enabled'] = true; | ||
| } | ||
| } else { | ||
| $this->data['enabled'] = false; | ||
| } | ||
|
|
||
| $extensions = $this->extensionCollection->getExtensions(); | ||
| $extensionEntries = []; | ||
| foreach ($extensions as $extension) { | ||
| $reflection = new \ReflectionClass($extension->getBundle()); | ||
| $extensionEntries[] = [ | ||
| 'name' => $reflection->getShortName(), | ||
| 'entries' => $extension->getEntries(), | ||
| ]; | ||
| } | ||
|
|
||
| $this->data['extensions'] = $extensionEntries; | ||
| } | ||
|
|
||
| public static function getTemplate(): ?string | ||
| { | ||
| return '@Contao/data_collector/huh_encore.html.twig'; | ||
| } | ||
|
|
||
| public function isEnabled(): bool | ||
| { | ||
| return $this->data['enabled'] ?? false; | ||
| } | ||
|
|
||
| public function getEntries(): array | ||
| { | ||
| return $this->data['entries'] ?? []; | ||
| } | ||
|
|
||
| public function getVersion(): string | ||
| { | ||
| return InstalledVersions::getPrettyVersion('heimrichhannot/contao-encore-bundle') ?? 'unknown'; | ||
| } | ||
|
|
||
| public function getExtensions(): array | ||
| { | ||
| return $this->data['extensions'] ?? []; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.