Skip to content

[Security][SecurityBundle] Dump role hierarchy as mermaid chart #61034

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

Open
wants to merge 13 commits into
base: 7.4
Choose a base branch
from
Open
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
Prev Previous commit
Next Next commit
review: use dumper direction const
  • Loading branch information
damienfern committed Jul 5, 2025
commit c120b3c349f89bbf9938c54311dc413b969b90c5
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@
#[AsCommand(name: 'debug:security:role-hierarchy', description: 'Dump the role hierarchy as a Mermaid flowchart')]
class SecurityRoleHierarchyDumpCommand extends Command
{
private const DIRECTION_OPTIONS = [
'TB',
'TD',
'BT',
'RL',
'LR',
];

public function __construct(
private readonly ?RoleHierarchyInterface $roleHierarchy = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

how can it be null via service declaration service() ?

Copy link
Member

Choose a reason for hiding this comment

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

We remove the role hierarchy service if you don't configure any hierarchy.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we then better remove this command as well ? useless to register a command if its to dump nothing

) {
Expand All @@ -48,7 +40,7 @@ protected function configure(): void
{
$this
->setDefinition([
new InputOption('direction', 'd', InputOption::VALUE_REQUIRED, 'The direction of the flowchart ['.implode('|', self::DIRECTION_OPTIONS).']', 'TB'),
new InputOption('direction', 'd', InputOption::VALUE_REQUIRED, 'The direction of the flowchart ['.implode('|', MermaidDumper::VALID_DIRECTIONS).']', MermaidDumper::DIRECTION_TOP_TO_BOTTOM),
Copy link
Member

Choose a reason for hiding this comment

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

please add support for completion by providing the valid choices

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't the completion method in the command okay for this ?

Copy link
Member

Choose a reason for hiding this comment

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

ah, I missed that you implemented this method. For static values, it is better to configure the completion values in the definition (and let symfony/console provide them) as it is simpler and also visible directly when looking at the definition that completion is supported.

new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'The output format', 'mermaid'),
])
->setHelp(<<<'USAGE'
Expand Down Expand Up @@ -76,8 +68,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::FAILURE;
}

if (!in_array($direction, self::DIRECTION_OPTIONS, true)) {
$output->writeln('<error>Invalid direction. Available options: '.implode(', ', self::DIRECTION_OPTIONS).'</error>');
if (!in_array($direction, MermaidDumper::VALID_DIRECTIONS, true)) {
$output->writeln('<error>Invalid direction. Available options: '.implode(', ', MermaidDumper::VALID_DIRECTIONS).'</error>');
return Command::FAILURE;
}

Expand All @@ -101,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
{
if ($input->mustSuggestOptionValuesFor('direction')) {
$suggestions->suggestValues(self::DIRECTION_OPTIONS);
$suggestions->suggestValues(MermaidDumper::VALID_DIRECTIONS);
}

if ($input->mustSuggestOptionValuesFor('format')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MermaidDumper
public const DIRECTION_RIGHT_TO_LEFT = 'RL';
public const DIRECTION_LEFT_TO_RIGHT = 'LR';

private const VALID_DIRECTIONS = [
public const VALID_DIRECTIONS = [
self::DIRECTION_TOP_TO_BOTTOM,
self::DIRECTION_TOP_DOWN,
self::DIRECTION_BOTTOM_TO_TOP,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy