File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
98
98
}
99
99
100
100
if ($ this ->workspaceCheckService ->spacenamesIsDuplicated ($ dataFormated )) {
101
- throw new \Exception ('Impossible to import your workspaces from the csv file. You have spacenames duplicated. ' );
101
+ $ message = "Impossible to import your workspaces from the csv file. \n" ;
102
+ $ message .= $ this ->getSpacenamesFromCsvFileDuplicated ($ dataFormated );
103
+ throw new \Exception ($ message );
102
104
}
103
105
104
106
$ message = $ this ->getSpacenamesDuplicated ($ dataFormated );
@@ -135,6 +137,25 @@ protected function configure(): void {
135
137
parent ::configure ();
136
138
}
137
139
140
+ private function getSpacenamesFromCsvFileDuplicated (array $ spaces ): string {
141
+ $ workspaceNames = [];
142
+ $ message = '' ;
143
+
144
+ foreach ($ spaces as $ space ) {
145
+ $ workspaceNames [] = $ space ['workspace_name ' ];
146
+ }
147
+
148
+ $ workspaceNamesDiff = array_values (
149
+ array_diff_assoc ($ workspaceNames , array_unique ($ workspaceNames ))
150
+ );
151
+
152
+ $ spacenamesFormated = array_map (fn ($ spacename ) => "- $ spacename \n" , $ workspaceNamesDiff );
153
+
154
+ $ message .= "The Workspace names below are duplicated: \n" . implode ('' , $ spacenamesFormated );
155
+
156
+ return $ message ;
157
+ }
158
+
138
159
private function getSpacenamesDuplicated (array $ dataResponse ): ?string {
139
160
$ workspacesAreNotExist = [];
140
161
$ message = "" ;
You can’t perform that action at this time.
0 commit comments