Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/TwigComponent/config/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\UX\TwigComponent\DataCollector\TwigComponentDataCollector;
use Symfony\UX\TwigComponent\EventListener\TwigComponentLoggerListener;

use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $container) {
Expand All @@ -27,6 +28,7 @@
->args([
service('ux.twig_component.component_logger_listener'),
service('twig'),
param('ux.twig_component.profiler_dump_components'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use an abstract arg here, and define the parameter on the definition after the load(debug.php) in the extension class... not sure we should create a parameter here

])
->tag('data_collector', [
'template' => '@TwigComponent/Collector/twig_component.html.twig',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ final class TwigComponentDataCollector extends AbstractDataCollector implements
public function __construct(
private readonly TwigComponentLoggerListener $logger,
private readonly Environment $twig,
private readonly bool $dumpComponents = true,
) {
$this->hasStub = class_exists(ClassStub::class);
}
Expand Down Expand Up @@ -130,12 +131,15 @@ private function collectDataFromLogger(): void
'input_props' => $mountedComponent->getInputProps(),
'attributes' => $mountedComponent->getAttributes()->all(),
'template_index' => $event->getTemplateIndex(),
'component' => $mountedComponent->getComponent(),
'depth' => \count($ongoingRenders),
'children' => [],
'render_start' => $profile[0],
];

if ($this->dumpComponents) {
$renders[$renderId]['component'] = $mountedComponent->getComponent();
}

if ($parentId = end($ongoingRenders)) {
$renders[$parentId]['children'][] = $renderId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function load(array $configs, ContainerBuilder $container): void
$defaults = [];
}
$container->setParameter('ux.twig_component.component_defaults', $defaults);
$container->setParameter('ux.twig_component.profiler_dump_components', $config['profiler_dump_components']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this then :)


$container->register('ux.twig_component.component_template_finder', ComponentTemplateFinder::class)
->setArguments([
Expand Down Expand Up @@ -219,6 +220,10 @@ public function getConfigTreeBuilder(): TreeBuilder
->info('Enables the profiler for Twig Component (in debug mode)')
->defaultValue('%kernel.debug%')
->end()
->booleanNode('profiler_dump_components')
->info('Enables the dump components for Twig Component (in debug mode)')
->defaultValue('%kernel.debug%')
->end()
Comment on lines +223 to +226
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultTrue() seems more logical here .. (its not just in debug mode but... when twig component profiler is enabled)

Without the parenthesis, probably something like

"Dump components in the Twig Component profiler panel"

wdyt ?

->scalarNode('controllers_json')
->setDeprecated('symfony/ux-twig-component', '2.18', 'The "twig_component.controllers_json" config option is deprecated, and will be removed in 3.0.')
->defaultNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,12 @@
<th scope="row">Attributes</th>
<td colspan="4">{{ profiler_dump(render.attributes) }}</td>
</tr>
{% if render.component is defined %}
<tr>
<th scope="row">Component</th>
<td colspan="4">{{ profiler_dump(render.component) }}</td>
</tr>
{% endif %}
</tbody>
</table>
{% endfor %}
Expand Down
Loading