@@ -254,6 +254,7 @@ if %$newSelectionId% equ %$currentPhpVersionId% goto currentSelectionGiven
254254
255255rem ---------------------------------
256256rem Update Users Environment Path
257+ rem TODO: Does this need to move down into is own block / function as well?
257258rem ---------------------------------
258259
259260rem Rebuild the users environmental path string excluding any and all previously
@@ -285,30 +286,81 @@ for /L %%a in (1,1,%$lastUsersEnvironmentalPathArrayId%) do (
285286)
286287
287288rem Add the selected PHP folder path to the end of the users environmental path string.
289+ rem : TODO: move down into setx path code block.
288290set $usersEnvironmentalPathString = %$usersEnvironmentalPathString%%$pathToPhpFolders% \!$availablePhpVersionsArray[%$newSelectionId%]!
289291
292+
293+ rem -------------------------------------------
294+ rem Perform action depending on entry point
295+ rem -------------------------------------------
296+
290297rem Check if the CLI session mode is being used.
291298if %$cliSessionMode% equ 1 (
292- rem Set 'session' path (which is a combination of both system and user environmental variables).
299+ rem Get path (which is a combination of both the system environmental path and the user environmental path).
300+
301+
302+ rem Explode the path.
303+ call :explodeEnvironmentalPath
293304
294- rem 1: %path% contains both system and user environmental variables .
295- rem 2: Get %path% string, remove 'permanent' php path and add 'temporary' php path.
305+ rem Remove any existing PHP version references .
306+ call : implodeEnvironmentalPathExcludingPhps
296307
297- echo Success: The session PHP CLI version is now !$availablePhpVersionsArray[%$newSelectionId%]!
308+ rem Add the selected PHP path.
309+ call :includeSelectedPhpPath
298310
311+ rem Message must come first as we loose reference to new selection variable.
312+ call :sessionUpdateSuccessful
313+
314+ rem Set the sessions environmental path variable.
299315 endlocal && set " Path = %$usersEnvironmentalPathString% " > nul
300316
301317 exit /B 0
302-
303318) else (
304- rem Set the user environmental variables.
319+ rem Get the users environmental path.
320+
321+
322+ rem Explode the path.
323+ call :explodeEnvironmentalPath
324+
325+ rem Remove any existing PHP version references.
326+ call :implodeEnvironmentalPathExcludingPhps
327+
328+ rem Add the selected PHP path.
329+ call :includeSelectedPhpPath
330+
331+ rem Set the user environmental path variable.
305332 setx path " %$usersEnvironmentalPathString% " > nul
333+
334+ rem Show the successful message.
335+ goto updateSuccessful
306336)
307337
308338
309- rem ------------------------------
310- rem Exit Subroutines - Success
311- rem ------------------------------
339+ rem ====================================================================================================================
340+ rem Functions
341+ rem ====================================================================================================================
342+
343+ rem Explode the environmental path string.
344+ :explodeEnvironmentalPath
345+
346+ exit /B
347+
348+
349+ rem Implode the environmental path string (whilst excluding any PHP versions).
350+ :implodeEnvironmentalPathExcludingPhps
351+
352+ exit /B
353+
354+
355+ rem Add the selected PHP path to environmental path string.
356+ :includeSelectedPhpPath
357+
358+ exit /B
359+
360+
361+ rem ====================================================================================================================
362+ rem Success Message
363+ rem ====================================================================================================================
312364
313365rem The update was successful.
314366:updateSuccessful
@@ -326,11 +378,18 @@ if %$cliMode% equ 0 (
326378)
327379
328380
329- rem -----------------------------
330- rem Exit Subroutines - Notice
331- rem -----------------------------
381+ rem The 'session' update was successful.
382+ :sessionUpdateSuccessful
383+
384+ echo Success: This sessions PHP CLI version is now !$availablePhpVersionsArray[%$newSelectionId%]!
385+
386+ exit /B
332387
333388
389+ rem ====================================================================================================================
390+ rem Notice Message
391+ rem ====================================================================================================================
392+
334393rem A current selection was given.
335394:currentSelectionGiven
336395
@@ -347,9 +406,9 @@ if %$cliMode% equ 0 (
347406)
348407
349408
350- rem ------------------------------
351- rem Exit Subroutines - Failure
352- rem ------------------------------
409+ rem ====================================================================================================================
410+ rem Failure Message
411+ rem ====================================================================================================================
353412
354413rem An invalid selection was given.
355414:invalidSelectionGiven
@@ -367,9 +426,9 @@ if %$cliMode% equ 0 (
367426)
368427
369428
370- rem ----------------------------
371- rem Exit Subroutines - Error
372- rem ----------------------------
429+ rem ====================================================================================================================
430+ rem Error Messages
431+ rem ====================================================================================================================
373432
374433rem An invalid $customInstallPath was given.
375434:invalidCustomInstallPathGiven
0 commit comments