---
title: "Context API and aspects"
manual: "TYPO3 Explained"
version: "14.3"
permalink: "https://docs.typo3.org/permalink/t3coreapi:context-api@14.3"
source: "ApiOverview/Context/Index.rst"
rendered: "2026-09-20T16:07:38+00:00"
---

# Context API and aspects {#context-api}

The Context API encapsulates various information for data retrieval (for
example, inside the database) and analysis of current permissions and caching
information.

The context is set up at the very beginning of each TYPO3 entry point, keeping
track of, for example, the current time, if a user is logged in and which
workspace is currently accessed.

The `\TYPO3\CMS\Core\Context\Context` object can be retrieved via
[dependency injection](https://docs.typo3.org/permalink/t3coreapi:dependencyinjection@14.3):

**EXT:my_extension/Classes/Controller/MyController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use TYPO3\CMS\Core\Context\Context;

final class MyController
{
  public function __construct(
    private readonly Context $context,
  ) {}
}

```

This information is separated in so-called
"[aspects](https://docs.typo3.org/permalink/t3coreapi:context-api-aspects@14.3)", each being responsible for a certain
area.

## Aspects {#context-api-aspects}

-   [Date time aspect](https://docs.typo3.org/permalink/t3coreapi:date-time-aspect@14.3)
-   [Language aspect](https://docs.typo3.org/permalink/t3coreapi:language-aspect@14.3)
-   [Preview aspect](https://docs.typo3.org/permalink/t3coreapi:preview-aspect@14.3)
-   [User aspect](https://docs.typo3.org/permalink/t3coreapi:user-aspect@14.3)
-   [Visibility aspect](https://docs.typo3.org/permalink/t3coreapi:visibility-aspect@14.3)
-   [Workspace aspect](https://docs.typo3.org/permalink/t3coreapi:workspace-aspect@14.3)

### Date time aspect {#context-api-aspects-datetime}

Contains time, date and timezone information for the current request.

The date time aspect, `\TYPO3\CMS\Core\Context\DateTimeAspect`, accepts
the following properties:

-   **timestamp**

    -   *Call:* `$this->context->getPropertyFromAspect('date', 'timestamp');`

    Returns the Unix timestamp as an integer value.

#### timezone {#datetime-aspect-timezone}

-   **timezone**

    -   *Call:* `$this->context->getPropertyFromAspect('date', 'timezone');`

    Returns the timezone name, for example, "Germany/Berlin".

#### iso {#datetime-aspect-iso}

-   **iso**

    -   *Call:* `$this->context->getPropertyFromAspect('date', 'iso');`

    Returns the datetime as string in
    [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, for example,
    "2004-02-12T15:19:21+00:00".

#### full {#datetime-aspect-full}

-   **full**

    -   *Call:* `$this->context->getPropertyFromAspect('date', 'full');`

    Returns the complete
    [\\DateTimeImmutable](https://www.php.net/manual/class.datetimeimmutable.php)
    object.

#### Example {#context-api-aspects-datetime-example}

**EXT:my_extension/Classes/Controller/MyController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use TYPO3\CMS\Core\Context\Context;

final class MyController
{
  public function __construct(
    private readonly Context $context,
  ) {}

  public function doSomething(): void
  {
    $currentTimestamp = $this->context->getPropertyFromAspect(
      'date',
      'timestamp',
    );

    // ... do something with $currentTimestamp
  }
}

```

### Language aspect {#context-api-aspects-language}

Contains information about language settings for the current
[request](https://docs.typo3.org/permalink/t3coreapi:typo3-request@14.3), including fallback and overlay logic.

The language aspect, `\TYPO3\CMS\Core\Context\LanguageAspect` accepts the
following properties:

-   **id**

    -   *Call:* `$this->context->getPropertyFromAspect('language', 'id');`

    Returns the requested language of the current page as integer (uid).

#### contentId {#language-aspect-contentid}

-   **contentId**

    -   *Call:* `$this->context->getPropertyFromAspect('language', 'contentId');`

    Returns the language ID of records to be fetched in translation scenarios as
    integer (uid).

#### fallbackChain {#language-aspect-fallbackchain}

-   **fallbackChain**

    -   *Call:* `$this->context->getPropertyFromAspect('language', 'fallbackChain');`

    Returns the fallback steps as array.

#### overlayType {#language-aspect-overlaytype}

-   **overlayType**

    -   *Call:* `$this->context->getPropertyFromAspect('language', 'overlayType');`

    Returns one of

    -   `LanguageAspect::OVERLAYS_OFF`
    -   `LanguageAspect::OVERLAYS_MIXED`
    -   `LanguageAspect::OVERLAYS_ON` or
    -   `LanguageAspect::OVERLAYS_ON_WITH_FLOATING` (default)

    See [Overlay types](https://docs.typo3.org/permalink/t3coreapi:context-api-aspects-language-overlay-types@14.3) for more details.

#### legacyLanguageMode {#language-aspect-legacylanguagemode}

-   **legacyLanguageMode**

    -   *Call:* `$this->context->getPropertyFromAspect('language', 'legacyLanguageMode');`

    Returns one of

    -   `strict`
    -   `ignore` or
    -   `content_fallback`.

    This property is kept for compatibility reasons. Do not use, if not really
    necessary, the option will be removed rather sooner than later.

#### legacyOverlayType {#language-aspect-legacyoverlaytype}

-   **legacyOverlayType**

    -   *Call:* `$this->context->getPropertyFromAspect('language', 'legacyOverlayType');`

    Returns one of

    -   `hideNonTranslated`
    -   `0` or
    -   `1`.

    This property is kept for compatibility reasons. Do not use, if not really
    necessary, the option will be removed rather sooner than later.

#### Overlay types {#context-api-aspects-language-overlay-types}

-   **`LanguageAspect::OVERLAYS_OFF`**

    Just fetch records from the selected language as given by
    `LanguageAspect->getContentId()`. No overlay will happen, no
    fetching of the records from the default language. This boils down to
    "free mode" language handling. Records without a default language parent are
    included.

-   **`LanguageAspect::OVERLAYS_MIXED`**

    Fetch records from the default language and overlay them with translations.
    If a record is not translated, the default language will be used.

-   **`LanguageAspect::OVERLAYS_ON`**

    Fetch records from the default language and overlay them with translations.
    If a record is not translated, it will not be displayed.

-   **`LanguageAspect::OVERLAYS_ON_WITH_FLOATING`**

    Fetch records from the default language and overlay them with translations.
    If a record is not translated, it will not be shown. Records without a
    default language parent are included.

#### Example {#context-api-aspects-language-example}

**EXT:my_extension/Classes/Controller/MyController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use TYPO3\CMS\Core\Context\Context;

final class MyController
{
  public function __construct(
    private readonly Context $context,
  ) {}

  public function doSomething(): void
  {
    $fallbackChain = $this->context->getPropertyFromAspect(
      'language',
      'fallbackChain',
    );

    // ... do something with $fallbackChain
  }
}

```

### Preview aspect {#context-api-aspects-preview}

The preview aspect may be used to indicate that the frontend is in preview mode
(for example, in case a workspace is previewed or hidden pages or records should
be shown).

The preview aspect, `\TYPO3\CMS\Frontend\Aspect\PreviewAspect`, contains
the following property:

-   **isPreview**

    -   *Call:* `$this->context->getPropertyFromAspect('frontend.preview', 'isPreview');`

Returns, whether the frontend is currently in preview mode.

### User aspect {#context-api-aspects-user}

Contains information about authenticated users in the current
[request](https://docs.typo3.org/permalink/t3coreapi:typo3-request@14.3). The aspect can be used for frontend and backend
users.

The user aspect, `\TYPO3\CMS\Core\Context\UserAspect`, accepts the
following properties:

-   **id**

    -   *Call:* `$this->context->getPropertyFromAspect('frontend.user', 'id');` or `$this->context->getPropertyFromAspect('backend.user', 'id');`

    Returns the uid of the currently logged in user, `0` if no user is logged
    in.

#### username {#user-aspect-username}

-   **username**

    -   *Call:* `$this->context->getPropertyFromAspect('frontend.user', 'username');` or `$this->context->getPropertyFromAspect('backend.user', 'username');`

    Returns the username of the currently authenticated user. Empty string, if
    no user is logged in.

#### isLoggedIn {#user-aspect-isloggedin}

-   **isLoggedIn**

    -   *Call:* `$this->context->getPropertyFromAspect('frontend.user', 'isLoggedIn');` or `$this->context->getPropertyFromAspect('backend.user', 'isLoggedIn');`

    Returns, whether a user is logged in, as boolean.

#### isAdmin {#user-aspect-isadmin}

-   **isAdmin**

    -   *Call:* `$this->context->getPropertyFromAspect('backend.user', 'isAdmin');`

    Returns, whether the user is an administrator, as boolean. It is only useful
    for backend users.

#### groupIds {#user-aspect-groupids}

-   **groupIds**

    -   *Call:* `$this->context->getPropertyFromAspect('frontend.user', 'groupIds');` or `$this->context->getPropertyFromAspect('backend.user', 'groupIds');`

    Returns the groups the user is a member of, as array.

#### groupNames {#user-aspect-groupnames}

-   **groupNames**

    -   *Call:* `$this->context->getPropertyFromAspect('frontend.user', 'groupNames');` or `$this->context->getPropertyFromAspect('backend.user', 'groupNames');`

    Returns the names of all groups the user belongs to, as array.

#### Example {#context-api-aspects-user-example}

**EXT:my_extension/Classes/Controller/MyController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use TYPO3\CMS\Core\Context\Context;

final class MyController
{
  public function __construct(
    private readonly Context $context,
  ) {}

  public function doSomething(): void
  {
    $userIsLoggedIn = $this->context->getPropertyFromAspect(
      'frontend.user',
      'isLoggedIn',
    );

    // ... do something with $userIsLoggedIn
  }
}

```

### Visibility aspect {#context-api-aspects-visibility}

The aspect contains whether to show hidden pages, records (content) or even
deleted records.

The visibility aspect, `\TYPO3\CMS\Core\Context\VisibilityAspect`, accepts
the following properties:

-   **includeHiddenPages**

    -   *Call:* `$this->context->getPropertyFromAspect('visibility', 'includeHiddenPages');`

    Returns, whether hidden pages should be displayed, as boolean.

#### includeHiddenContent {#visibility-aspect-includehiddencontent}

-   **includeHiddenContent**

    -   *Call:* `$this->context->getPropertyFromAspect('visibility', 'includeHiddenContent');`

    Returns, whether hidden content should be displayed, as boolean.

#### includeDeletedRecords {#visibility-aspect-includedeletedrecords}

-   **includeDeletedRecords**

    -   *Call:* `$this->context->getPropertyFromAspect('visibility', 'includeDeletedRecords');`

    Returns, whether deleted records should be displayed, as boolean.

#### Example {#context-api-aspects-visibility-example}

**EXT:my_extension/Classes/Controller/MyController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use TYPO3\CMS\Core\Context\Context;

final class MyController
{
  public function __construct(
    private readonly Context $context,
  ) {}

  public function doSomething(): void
  {
    $showHiddenPages = $this->context->getPropertyFromAspect(
      'visibility',
      'includeHiddenPages',
    );

    // ... do something with $showHiddenPages
  }
}

```

### Workspace aspect {#context-api-aspects-workspace}

The aspect contains information about the currently accessed
[workspace](https://docs.typo3.org/permalink/t3coreapi:workspaces@14.3).

The workspace aspect, `\TYPO3\CMS\Core\Context\WorkspaceAspect`, accepts
the following properties:

-   **id**

    -   *Call:* `$this->context->getPropertyFromAspect('workspace', 'id');`

    Returns the UID of the currently accessed workspace, as integer.

#### isLive {#workspace-aspect-islive}

-   **isLive**

    -   *Call:* `$this->context->getPropertyFromAspect('workspace', 'isLive');`

    Returns whether the current workspace is live, or a custom offline
    workspace, as boolean.

#### isOffline {#workspace-aspect-isoffline}

-   **isOffline**

    -   *Call:* `$this->context->getPropertyFromAspect('workspace', 'isOffline');`

    Returns, whether the current workspace is offline, as boolean.

#### Example {#context-api-aspects-workspace-example}

**EXT:my_extension/Classes/Controller/MyController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use TYPO3\CMS\Core\Context\Context;

final class MyController
{
  public function __construct(
    private readonly Context $context,
  ) {}

  public function doSomething(): void
  {
    $showHiddenPages = $this->context->getPropertyFromAspect(
      'workspace',
      'id',
    );

    // ... do something with $showHiddenPages
  }
}

```
