‪TYPO3CMS  10.4
EnvironmentService.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
27 {
31  protected ‪$isFrontendMode;
32 
38  public function ‪isEnvironmentInFrontendMode(): bool
39  {
40  $this->‪initialize();
41  if ($this->isFrontendMode !== null) {
43  }
44  return (defined('TYPO3_MODE') && TYPO3_MODE === 'FE') ?: false;
45  }
46 
52  public function ‪isEnvironmentInBackendMode(): bool
53  {
54  return !$this->‪isEnvironmentInFrontendMode();
55  }
56 
57  protected function ‪initialize(): void
58  {
59  if ($this->isFrontendMode !== null) {
60  return;
61  }
62  if (defined('TYPO3_MODE')) {
63  $this->isFrontendMode = TYPO3_MODE === 'FE';
64  }
65  }
66 
73  public function ‪setFrontendMode(bool ‪$isFrontendMode): void
74  {
75  $this->isFrontendMode = ‪$isFrontendMode;
76  }
77 }
‪TYPO3\CMS\Extbase\Service\EnvironmentService\initialize
‪initialize()
Definition: EnvironmentService.php:56
‪TYPO3\CMS\Extbase\Service
Definition: CacheService.php:18
‪TYPO3\CMS\Extbase\Service\EnvironmentService
Definition: EnvironmentService.php:27
‪TYPO3\CMS\Extbase\Service\EnvironmentService\isEnvironmentInFrontendMode
‪bool isEnvironmentInFrontendMode()
Definition: EnvironmentService.php:37
‪TYPO3\CMS\Extbase\Service\EnvironmentService\$isFrontendMode
‪bool null $isFrontendMode
Definition: EnvironmentService.php:30
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:23
‪TYPO3\CMS\Extbase\Service\EnvironmentService\setFrontendMode
‪setFrontendMode(bool $isFrontendMode)
Definition: EnvironmentService.php:72
‪TYPO3\CMS\Extbase\Service\EnvironmentService\isEnvironmentInBackendMode
‪bool isEnvironmentInBackendMode()
Definition: EnvironmentService.php:51