[FEATURE] Use EnvironmentService to detect TYPO3_MODE in several places

In several places the TYPO3_MODE is still detected by
checking the TYPO3_MODE constant directly. This patch
replaces the checks by using the EnvironmentService.

Releases: 6.1
Resolves: #46396
Change-Id: I2f58e1ca175a86845beb053440428cc42f093847
Reviewed-on: https://review.typo3.org/19006
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring