-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[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
base: 7.4
Are you sure you want to change the base?
Changes from 1 commit
02f2761
dcfe489
d1a118c
c120b3c
bac240e
8e135fe
a61751b
c39867b
cfc4e24
b21d28d
0b86dfa
4ff1b49
96d1fda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
) { | ||
|
@@ -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), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add support for completion by providing the valid choices There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the completion method in the command okay for this ? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'The output format', 'mermaid'), | ||
welcoMattic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
]) | ||
->setHelp(<<<'USAGE' | ||
|
@@ -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>'); | ||
welcoMattic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return Command::FAILURE; | ||
} | ||
|
||
|
@@ -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')) { | ||
|
There was a problem hiding this comment.
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()
?There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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