Skip to content

Commit

Permalink
[FEATURE] #101807 - Automatic inclusion of user TSconfig of extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
brotkrueml committed Oct 8, 2023
1 parent 4053f00 commit 458e9c7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 30 deletions.
10 changes: 4 additions & 6 deletions Documentation/UserTsconfig/Options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -974,14 +974,12 @@ passwordReset
cli command.

To completely disable the password reset in the backend for all users, you can
set the user TSconfig globally in your :file:`ext_localconf.php`:
set the user TSconfig globally in your :file:`Configuration/user.tsconfig`:

.. code-block:: php
:caption: EXT:site_package/ext_localconf.php
.. code-block:: typoscript
:caption: EXT:site_package/Configuration/user.tsconfig
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
'options.passwordReset = 0'
);
options.passwordReset = 0
If required, this setting can be overridden on a per user basis
in the corresponding :guilabel:`TSconfig` field of the backend
Expand Down
42 changes: 32 additions & 10 deletions Documentation/UsingSetting/UserTSconfig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,50 @@ both define the same property.
Setting default user TSconfig
=============================

.. versionadded:: 13.0
Starting with TYPO3 v12.0 page TSconfig in a file named
:file:`Configuration/user.tsconfig` in an extension is automatically loaded
during build time.

User TSconfig is designed to be individual for users or groups of
users. However, good defaults can be defined and overridden by group or
user-specific TSconfig.

In extensions, this is done using the Core API function,
:php:`\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig()`.
In the :file:`ext_localconf.php` file of your extension you can call it
like this to set a default configuration.
Default page TSconfig should be stored within an extension, usually a
sitepackage extension. The content of the file
:file:`Configuration/user.tsconfig` within an extension is automatically loaded
during build time.

It is possible to load other user TSconfig files with the import syntax within
this file:

.. code-block:: typoscript
:caption: EXT:my_extension/Configuration/user.tsconfig
@import 'EXT:my_sitepackage/Configuration/TsConfig/User/default.tsconfig'
.. literalinclude:: _UserTSconfig/_ext_localconf.php
User TSconfig, compatible with TYPO3 v12 and v13
------------------------------------------------

In TYPO3 v12 installations the content of :file:`Configuration/user.tsconfig` is
not loaded automatically. You can achieve compatibility with both TYPO3 v12 and
v13 by importing the content of this file with the API function
:php:`ExtensionManagementUtility::addUserTSConfig`:

.. literalinclude:: _UserTSconfig/_ext_localconf_v12.php
:language: php
:caption: EXT:my_sitepackage/ext_localconf.php

There is a global :ref:`TYPO3_CONF_VARS <t3coreapi:typo3ConfVars>` value called
:ref:`$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'] <t3coreapi:typo3ConfVars_be_defaultUserTSconfig>`.
The API function above adds content to that array. However, the array value
itself should **not** be changed or set directly without using the API.

.. deprecated:: 13.0
The method :php:`\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig()`
has been marked as deprecated in TYPO3 v13 and will be removed with TYPO3
v14.

.. index:: pair: User TSconfig; Verify configuration
.. _userverifyingthefinalconfiguration:


Verify the final configuration
==============================

Expand Down
14 changes: 0 additions & 14 deletions Documentation/UsingSetting/_UserTSconfig/_ext_localconf.php

This file was deleted.

17 changes: 17 additions & 0 deletions Documentation/UsingSetting/_UserTSconfig/_ext_localconf_v12.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

defined('TYPO3') or die();

$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
// Only include user.tsconfig if TYPO3 version is below 13 so that it is not imported twice.
if ($versionInformation->getMajorVersion() < 13) {
ExtensionManagementUtility::addUserTSConfig(
'@import "EXT:my_sitepackage/Configuration/user.tsconfig"'
);
}

0 comments on commit 458e9c7

Please sign in to comment.