diff --git a/src/Sylius/Bundle/UiBundle/Command/DebugTemplateEventCommand.php b/src/Sylius/Bundle/UiBundle/Command/DebugTemplateEventCommand.php new file mode 100644 index 0000000000..d31ae14730 --- /dev/null +++ b/src/Sylius/Bundle/UiBundle/Command/DebugTemplateEventCommand.php @@ -0,0 +1,78 @@ +templateBlockRegistry = $templateBlockRegistry; + } + + protected function configure(): void + { + $this + ->setDescription('Debug template events and associated blocks') + ->addArgument('event', InputArgument::OPTIONAL, 'Template event name', null) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + $eventName = $input->getArgument('event'); + + if ($eventName === null) { + $io->title('List of template events'); + + $io->listing(array_keys($this->templateBlockRegistry->all())); + + return 0; + } + + $io->title(sprintf('Blocks registered for the template event "%s"', $eventName)); + + $io->table( + ['Block name', 'Template', 'Priority', 'Enabled'], + array_map( + static function (TemplateBlock $templateBlock): array { + return [ + $templateBlock->getName(), + $templateBlock->getTemplate(), + $templateBlock->getPriority(), + $templateBlock->isEnabled() ? 'TRUE' : 'FALSE', + ]; + }, + $this->templateBlockRegistry->all()[$eventName] ?? [] + ) + ); + + return 0; + } +} diff --git a/src/Sylius/Bundle/UiBundle/Resources/config/services/template_event.xml b/src/Sylius/Bundle/UiBundle/Resources/config/services/template_event.xml index 7327f78e00..44b115036e 100644 --- a/src/Sylius/Bundle/UiBundle/Resources/config/services/template_event.xml +++ b/src/Sylius/Bundle/UiBundle/Resources/config/services/template_event.xml @@ -26,5 +26,10 @@ + + + + +