Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Adding priority to ibexa data collector
  • Loading branch information
MateuszKolankowski committed Mar 25, 2025
commit 865140303d6e8dd6e005dc2991fe187701eefcb4
31 changes: 21 additions & 10 deletions src/bundle/Debug/DependencyInjection/Compiler/DataCollectorPass.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check warning on line 1 in src/bundle/Debug/DependencyInjection/Compiler/DataCollectorPass.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.3)

Found violation(s) of type: function_declaration

Check warning on line 1 in src/bundle/Debug/DependencyInjection/Compiler/DataCollectorPass.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.3)

Found violation(s) of type: static_lambda

Check warning on line 1 in src/bundle/Debug/DependencyInjection/Compiler/DataCollectorPass.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.3)

Found violation(s) of type: header_comment

Check warning on line 1 in src/bundle/Debug/DependencyInjection/Compiler/DataCollectorPass.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.3)

Found violation(s) of type: blank_lines_before_namespace

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
Expand All @@ -20,18 +20,29 @@
}

$dataCollectorDef = $container->getDefinition(IbexaCoreCollector::class);
foreach ($container->findTaggedServiceIds('ibexa.debug.data_collector') as $id => $attributes) {
foreach ($attributes as $attribute) {
$dataCollectorDef->addMethodCall(
'addCollector',
[
new Reference($id),
isset($attribute['panelTemplate']) ? $attribute['panelTemplate'] : null,
isset($attribute['toolbarTemplate']) ? $attribute['toolbarTemplate'] : null,
]
);
$collectors = [];

foreach ($container->findTaggedServiceIds('ibexa.debug.data_collector') as $id => $tags) {
foreach ($tags as $attributes) {
$priority = $attributes['priority'] ?? 0;
$collectors[] = [
'id' => $id,
'priority' => $priority,
'panelTemplate' => $attributes['panelTemplate'] ?? null,
'toolbarTemplate' => $attributes['toolbarTemplate'] ?? null,
];
}
}

usort($collectors, fn($a, $b) => $b['priority'] <=> $a['priority']);

foreach ($collectors as $collector) {
$dataCollectorDef->addMethodCall('addCollector', [
new Reference($collector['id']),
$collector['panelTemplate'],
$collector['toolbarTemplate'],
]);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/bundle/Debug/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
id: "ezpublish.debug.siteaccess"
panelTemplate: '@IbexaDebug/Profiler/siteaccess/panel.html.twig'
toolbarTemplate: '@IbexaDebug/Profiler/siteaccess/toolbar.html.twig'
priority: 200

Ibexa\Bundle\Debug\Collector\PersistenceCacheCollector:
class: Ibexa\Bundle\Debug\Collector\PersistenceCacheCollector
Expand All @@ -25,3 +26,4 @@ services:
id: "ezpublish.debug.persistence"
panelTemplate: '@IbexaDebug/Profiler/persistence/panel.html.twig'
toolbarTemplate: '@IbexaDebug/Profiler/persistence/toolbar.html.twig'
priority: 100
Loading