‪TYPO3CMS  11.5
TYPO3\CMS\Core\Http\ApplicationType Class Reference

Public Member Functions

 isFrontend ()
 
 isBackend ()
 

Static Public Member Functions

static static fromRequest (ServerRequestInterface $request)
 

Private Member Functions

 __construct (int $type)
 

Private Attributes

int $type = 0
 

Detailed Description

Helper class to answer "Is this a frontend or backend request?".

It requires a PSR-7 ServerRequestInterface request object. Typical usage:

ApplicationType::fromRequest($request)->isFrontend()

Note the final request object is given to your controller by the frontend and backend RequestHandler's. This request should be used in code calling this class. However, various library parts of the TYPO3 core do not receive the request object directly, so extensions may not receive it either. To work around this technical debt for now, the RequestHandler's set the final request object as $GLOBALS['TYPO3_REQUEST'], which can be used in those cases to feed this class. Also note that CLI calls often do NOT create a request object, depending on their task.

Classes that may be called from CLI without request object thus use this helper like:

// Do something special if this is a frontend request.
if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
    && ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()
) {

Important: $GLOBALS['TYPO3_REQUEST'] is NOT available before the RequestHandler has been called. This especially means the question "Is this a frontend or backend request?" can NOT be answered in the TYPO3 bootstrap related extension files ext_localconf.php, ext_tables.php and Configuration/TCA/* files.

Definition at line 51 of file ApplicationType.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Http\ApplicationType::__construct ( int  $type)
private

Definition at line 74 of file ApplicationType.php.

References TYPO3\CMS\Core\Http\ApplicationType\$type.

Member Function Documentation

◆ fromRequest()

static static TYPO3\CMS\Core\Http\ApplicationType::fromRequest ( ServerRequestInterface  $request)
static

Create an ApplicationType object from a given PSR-7 request.

Parameters
ServerRequestInterface$request
Returns
‪static
Exceptions
RuntimeException

Definition at line 62 of file ApplicationType.php.

References TYPO3\CMS\Core\Http\ApplicationType\$type.

Referenced by TYPO3\CMS\Core\Resource\ResourceCompressor\__construct(), TYPO3\CMS\IndexedSearch\FileContentParser\__construct(), TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolver\__construct(), TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings\__construct(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue(), TYPO3\CMS\Backend\Security\CategoryPermissionsAspect\addUserPermissionsToCategoryTreeData(), TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\addUserPermissionsToStorage(), TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder\build(), TYPO3\CMS\Backend\Resource\Processing\DeferredBackendImageProcessor\canProcessTask(), TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\checkIncludeLines(), TYPO3\CMS\Core\Utility\DebugUtility\debug(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateExpression(), TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\fromRequestThrowsIfTypeIsMissing(), TYPO3\CMS\Extbase\Mvc\Request\getBaseUri(), TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager\getConfiguration(), TYPO3\CMS\Core\Resource\ResourceFactory\getFileReferenceData(), TYPO3\CMS\Core\Error\ErrorHandler\getFormattedLogMessage(), TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\getGlobalInstance(), TYPO3\CMS\Extbase\Service\ImageService\getImageFromSourceString(), TYPO3\CMS\Extbase\Utility\LocalizationUtility\getLanguageKeys(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\getUidOfAlreadyPersistedValueObject(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getVisibilityConstraintStatement(), TYPO3\CMS\Extbase\Service\EnvironmentService\initialize(), TYPO3\CMS\Extbase\Configuration\ConfigurationManager\initializeConcreteConfigurationManager(), TYPO3\CMS\Form\Domain\Runtime\FormRuntime\initializeHoneypotFromRequest(), TYPO3\CMS\Fluid\View\TemplatePaths\isBackendMode(), TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isBackendReturnsTrueIfBackend(), TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isBackendReturnsTrueIfNotBackend(), TYPO3\CMS\Extbase\Service\EnvironmentService\isEnvironmentInFrontendMode(), TYPO3\CMS\Fluid\View\TemplatePaths\isFrontendMode(), TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isFrontendReturnsFalseIfNotFrontend(), TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isFrontendReturnsTrueIfFrontend(), TYPO3\CMS\Core\Resource\ResourceStorage\isOnline(), TYPO3\CMS\Frontend\Aspect\FileMetadataOverlayAspect\languageAndWorkspaceOverlay(), TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManager\overrideConfigurationByTypoScript(), TYPO3\CMS\Fluid\ViewHelpers\Link\EmailViewHelper\render(), TYPO3\CMS\Form\Domain\Runtime\FormRuntime\renderHoneypot(), TYPO3\CMS\Fluid\ViewHelpers\Uri\EmailViewHelper\renderStatic(), TYPO3\CMS\Fluid\ViewHelpers\BaseViewHelper\renderStatic(), TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper\renderStatic(), TYPO3\CMS\Core\Messaging\FlashMessageRendererResolver\resolveContext(), TYPO3\CMS\Form\Service\TranslationService\setLanguageKeys(), TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder\uriFor(), TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter\writeLog(), and TYPO3\CMS\Core\Error\AbstractExceptionHandler\writeLogEntries().

◆ isBackend()

TYPO3\CMS\Core\Http\ApplicationType::isBackend ( )

◆ isFrontend()

TYPO3\CMS\Core\Http\ApplicationType::isFrontend ( )

Member Data Documentation

◆ $type

int TYPO3\CMS\Core\Http\ApplicationType::$type = 0
private