File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
apps/user_ldap/lib/Command Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -31,11 +31,34 @@ protected function configure(): void {
3131 InputOption::VALUE_NONE ,
3232 'outputs only the prefix '
3333 )
34+ ->addOption (
35+ 'set-prefix ' ,
36+ 's ' ,
37+ InputOption::VALUE_OPTIONAL ,
38+ 'manually set the prefix (must be unique) ' ,
39+ )
3440 ;
3541 }
3642
3743 protected function execute (InputInterface $ input , OutputInterface $ output ): int {
38- $ configPrefix = $ this ->helper ->getNextServerConfigurationPrefix ();
44+ $ configPrefix = $ input ->getOption ('set-prefix ' );
45+ if (is_string ($ configPrefix )) {
46+ if ($ configPrefix === '' ) {
47+ $ output ->writeln ('The prefix cannot be empty ' );
48+ return self ::FAILURE ;
49+ }
50+ if (preg_match ('/^[a-zA-Z0-9-_]+$/ ' , $ configPrefix ) !== 1 ) {
51+ $ output ->writeln ('The prefix may only contain alphanumeric characters, dashes and underscores ' );
52+ return self ::FAILURE ;
53+ }
54+ $ availableConfigs = $ this ->helper ->getServerConfigurationPrefixes ();
55+ if (in_array ($ configPrefix , $ availableConfigs )) {
56+ $ output ->writeln ('The prefix is already in use ' );
57+ return self ::FAILURE ;
58+ }
59+ } else {
60+ $ configPrefix = $ this ->helper ->getNextServerConfigurationPrefix ();
61+ }
3962 $ configHolder = new Configuration ($ configPrefix );
4063 $ configHolder ->ldapConfigurationActive = false ;
4164 $ configHolder ->saveConfiguration ();
You can’t perform that action at this time.
0 commit comments