@@ -254,6 +254,7 @@ if %$newSelectionId% equ %$currentPhpVersionId% goto currentSelectionGiven
254
254
255
255
rem ---------------------------------
256
256
rem Update Users Environment Path
257
+ rem TODO: Does this need to move down into is own block / function as well?
257
258
rem ---------------------------------
258
259
259
260
rem Rebuild the users environmental path string excluding any and all previously
@@ -285,30 +286,81 @@ for /L %%a in (1,1,%$lastUsersEnvironmentalPathArrayId%) do (
285
286
)
286
287
287
288
rem 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.
288
290
set $usersEnvironmentalPathString = %$usersEnvironmentalPathString%%$pathToPhpFolders% \!$availablePhpVersionsArray[%$newSelectionId%]!
289
291
292
+
293
+ rem -------------------------------------------
294
+ rem Perform action depending on entry point
295
+ rem -------------------------------------------
296
+
290
297
rem Check if the CLI session mode is being used.
291
298
if %$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
293
304
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
296
307
297
- echo Success: The session PHP CLI version is now !$availablePhpVersionsArray[%$newSelectionId%]!
308
+ rem Add the selected PHP path.
309
+ call :includeSelectedPhpPath
298
310
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.
299
315
endlocal && set " Path = %$usersEnvironmentalPathString% " > nul
300
316
301
317
exit /B 0
302
-
303
318
) 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.
305
332
setx path " %$usersEnvironmentalPathString% " > nul
333
+
334
+ rem Show the successful message.
335
+ goto updateSuccessful
306
336
)
307
337
308
338
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 ====================================================================================================================
312
364
313
365
rem The update was successful.
314
366
:updateSuccessful
@@ -326,11 +378,18 @@ if %$cliMode% equ 0 (
326
378
)
327
379
328
380
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
332
387
333
388
389
+ rem ====================================================================================================================
390
+ rem Notice Message
391
+ rem ====================================================================================================================
392
+
334
393
rem A current selection was given.
335
394
:currentSelectionGiven
336
395
@@ -347,9 +406,9 @@ if %$cliMode% equ 0 (
347
406
)
348
407
349
408
350
- rem ------------------------------
351
- rem Exit Subroutines - Failure
352
- rem ------------------------------
409
+ rem ====================================================================================================================
410
+ rem Failure Message
411
+ rem ====================================================================================================================
353
412
354
413
rem An invalid selection was given.
355
414
:invalidSelectionGiven
@@ -367,9 +426,9 @@ if %$cliMode% equ 0 (
367
426
)
368
427
369
428
370
- rem ----------------------------
371
- rem Exit Subroutines - Error
372
- rem ----------------------------
429
+ rem ====================================================================================================================
430
+ rem Error Messages
431
+ rem ====================================================================================================================
373
432
374
433
rem An invalid $customInstallPath was given.
375
434
:invalidCustomInstallPathGiven
0 commit comments