Targets
The enum \TYPO3\CMS\Core\Action\Target defines the channels of an action:
Target::backendTarget::httpTarget::ai| Target | Channel | Authentication |
|---|---|---|
Target::backend | The backend user interface, see Calling the API from backend JavaScript | The session of the logged-in backend user |
Target::http | The HTTP API for external applications and the OpenAPI document | The access tokens of apps |
Target::ai | Tools for language models | — |
Most actions have all targets. Restrict an action to the backend if only the
backend user interface uses it, for example because its result fits one
component. Such an action is not in the OpenAPI document. A request with the
access token of an app gets the status 404:
use TYPO3\CMS\Core\Action\Target;
#[AsAction(
route: 'my-extension/tree/configuration',
targets: [Target::backend],
)]
public function configuration(): array
{
// …
}
php
use TYPO3\CMS\Core\Action\Target;
#[AsAction(
route: 'my-extension/tree/configuration',
targets: [Target::backend],
)]
public function configuration(): array
{
// …
}
TYPO3 does not accept an empty list of targets when it compiles the dependency injection container.