Commit 24c5372a authored by Oliver Klee's avatar Oliver Klee Committed by Stefan Bürk
Browse files

[TASK] Properly deprecate the check for the SiteLanguageAwareTrait

In #87380, it was recommended to use the `SiteLanguageAwareInterface`
instead of the `SiteLanguageAwareTrait` for marking classes as site
language aware. The usage of the trait for this was never properly
deprecated - it was only marked as "at any time after TYPO3 v11",
which is not specific enough.

The proper deprecation is now done so the check for the trait can
be removed for TYPO3 v13.

Resolves: #97435
Related: #87380
Releases: main
Change-Id: I6e8d130b295d4dc3f69639b4fa0e13d6b73f1040

Tested-by: core-ci's avatarcore-ci <>
Tested-by: Oliver Hader's avatarOliver Hader <>
Tested-by: Stefan Bürk's avatarStefan Bürk <>
Reviewed-by: Simon Schaufelberger's avatarSimon Schaufelberger <>
Reviewed-by: Oliver Hader's avatarOliver Hader <>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <>
parent f8016368
......@@ -114,10 +114,19 @@ class AspectFactory
protected function enrich(AspectInterface $aspect, SiteLanguage $language, Site $site): AspectInterface
// the check for the trait is @deprecated and can be removed at any time after TYPO3 v11
// The check for the trait is @deprecated and will be removed in TYPO3 v13
if ($aspect instanceof SiteLanguageAwareInterface || in_array(SiteLanguageAwareTrait::class, class_uses($aspect) ?: [], true)) {
/** @var AspectInterface|SiteLanguageAwareInterface $aspect */
if (!$aspect instanceof SiteLanguageAwareInterface) {
'The class "' . get_class($aspect) . '" uses the (internal) TYPO3\CMS\Core\Site\SiteLanguageAwareTrait instead of implementing '
. 'TYPO3\CMS\Core\Site\SiteLanguageAwareInterface to mark the class as language-aware. Using the trait for this purpose will stop working '
. 'in TYPO3 v13. Please implement the interface for this.',
if ($aspect instanceof SiteAwareInterface) {
.. include:: /Includes.rst.txt
Deprecation: #97435 - Usage of SiteLanguageAwareTrait to denote site language awareness
See :issue:`97435`
The :php:`TYPO3\CMS\Core\Site\SiteLanguageAwareTrait` should not be used as
means to denote a class as aware of the site language anymore. Instead, the
:php:`TYPO3\CMS\Core\Site\SiteLanguageAwareInterface` should be implemented for
this purpose. The trait is an internal implementation and should not be used
in user land code.
If you are currently using the :php:`SiteLanguageAwareTrait` to denote a class
as aware of the site language, you should implement the
:php:`SiteLanguageAwareInterface` instead.
Affected Installations
All installations where the :php:`SiteLanguageAwareTrait` is used to denote
a class as aware of the site language.
Change classes that use the :php:`SiteLanguageAwareTrait` but not the
corresponding interface to implement the interface. Replace the usage of the
trait with an own trait, or implement the interface methods directly in the
Example before the migration:
.. code-block:: php
use TYPO3\CMS\Core\Site\SiteLanguageAwareTrait;
class MyClass
use SiteLanguageAwareTrait;
Example after the migration:
.. code-block:: php
use TYPO3\CMS\Core\Site\SiteLanguageAwareInterface;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
class MyClass implements SiteLanguageAwareInterface
protected SiteLanguage $siteLanguage;
public function setSiteLanguage(SiteLanguage $siteLanguage)
$this->siteLanguage = $siteLanguage;
public function getSiteLanguage(): SiteLanguage
return $this->siteLanguage;
.. index:: PHP-API, ext:core, NotScanned
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment