|
15 | 15 |
|
16 | 16 | class LdapGroupSyncCommand extends \Symfony\Component\Console\Command\Command |
17 | 17 | { |
18 | | - private $logger = null; |
19 | | - private $dryRun = false; |
20 | | - |
21 | | - private $slugifyGitlabName = null; |
22 | | - private $slugifyGitlabPath = null; |
| 18 | + private $logger = null; |
| 19 | + private $dryRun = false; |
23 | 20 |
|
24 | 21 | /** |
25 | 22 | * Configures the current command. |
@@ -51,20 +48,6 @@ public function execute(InputInterface $input, OutputInterface $output): ?int |
51 | 48 | $this->logger->warning("Dry run enabled: No changes will be persisted."); |
52 | 49 | } |
53 | 50 |
|
54 | | - $this->slugifyGitlabName = new Slugify([ |
55 | | - "regexp" => "/([^A-Za-z0-9]|-_\. )+/", |
56 | | - "separator" => " ", |
57 | | - "lowercase" => false, |
58 | | - "trim" => true, |
59 | | - ]); |
60 | | - |
61 | | - $this->slugifyGitlabPath = new Slugify([ |
62 | | - "regexp" => "/([^A-Za-z0-9]|-_\.)+/", |
63 | | - "separator" => "-", |
64 | | - "lowercase" => true, |
65 | | - "trim" => true, |
66 | | - ]); |
67 | | - |
68 | 51 |
|
69 | 52 |
|
70 | 53 | // Load configuration |
@@ -763,6 +746,20 @@ private function getLdapGroupsAndUsers(array $config, array &$groups, int &$grou |
763 | 746 | */ |
764 | 747 | private function deployGitlabGroupsAndUsers(array $config, string $gitlabInstance, array $gitlabConfig, array $ldapGroups, int $ldapGroupsNum, array $ldapUsers, int $ldapUsersNum): void |
765 | 748 | { |
| 749 | + $slugifyGitlabName = new Slugify([ |
| 750 | + "regexp" => "/([^A-Za-z0-9]|-_\. )+/", |
| 751 | + "separator" => " ", |
| 752 | + "lowercase" => false, |
| 753 | + "trim" => true, |
| 754 | + ]); |
| 755 | + |
| 756 | + $slugifyGitlabPath = new Slugify([ |
| 757 | + "regexp" => "/([^A-Za-z0-9]|-_\.)+/", |
| 758 | + "separator" => "-", |
| 759 | + "lowercase" => true, |
| 760 | + "trim" => true, |
| 761 | + ]); |
| 762 | + |
766 | 763 | // Connect |
767 | 764 | $this->logger->notice("Establishing Gitlab connection.", [ |
768 | 765 | "instance" => $gitlabInstance, |
@@ -842,8 +839,8 @@ private function deployGitlabGroupsAndUsers(array $config, string $gitlabInstanc |
842 | 839 | continue; |
843 | 840 | } |
844 | 841 |
|
845 | | - $gitlabGroupName = $this->slugifyGitlabName->slugify($ldapGroupName); |
846 | | - $gitlabGroupPath = $this->slugifyGitlabPath->slugify($ldapGroupName); |
| 842 | + $gitlabGroupName = $slugifyGitlabName->slugify($ldapGroupName); |
| 843 | + $gitlabGroupPath = $slugifyGitlabPath->slugify($ldapGroupName); |
847 | 844 |
|
848 | 845 | if (!in_array($gitlabGroupName, $groupsSync["found"])) { |
849 | 846 | $this->logger->info(sprintf("Directory group \"%s\" is not in Gitlab.", $ldapGroupName)); |
@@ -872,7 +869,7 @@ private function deployGitlabGroupsAndUsers(array $config, string $gitlabInstanc |
872 | 869 | continue; |
873 | 870 | } |
874 | 871 |
|
875 | | - $gitlabGroupPath = $this->slugifyGitlabPath->slugify($gitlabGroupName); |
| 872 | + $gitlabGroupPath = $slugifyGitlabPath->slugify($gitlabGroupName); |
876 | 873 |
|
877 | 874 | if (!in_array($gitlabGroupName, $ldapGroups)) { |
878 | 875 | $this->logger->info(sprintf("Gitlab group \"%s\" is not in directory.", $gitlabGroupName)); |
@@ -903,7 +900,7 @@ private function deployGitlabGroupsAndUsers(array $config, string $gitlabInstanc |
903 | 900 | continue; |
904 | 901 | } |
905 | 902 |
|
906 | | - $gitlabGroupPath = $this->slugifyGitlabPath->slugify($gitlabGroupName); |
| 903 | + $gitlabGroupPath = $slugifyGitlabPath->slugify($gitlabGroupName); |
907 | 904 |
|
908 | 905 | $usersSync = [ |
909 | 906 | "found" => [], |
|
0 commit comments