Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation: #105252 - DataProviderContext getters and setters #4327

Open
simonschaufi opened this issue Oct 15, 2024 · 0 comments
Open

Deprecation: #105252 - DataProviderContext getters and setters #4327

simonschaufi opened this issue Oct 15, 2024 · 0 comments

Comments

@simonschaufi
Copy link
Collaborator

Deprecation: #105252 - DataProviderContext getters and setters

https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.4/Deprecation-105252-DataProviderContextGettersAndSetters.html

Deprecation: #105252 - DataProviderContext getters and setters

See 105252

Description

The backend layout related data object class
TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext has been
turned into a data object using public constructor property promotion
(PCPP). All setX() and getX() methods have been marked as deprecated
in TYPO3 v13.4 and will be removed with TYPO3 v14.0. The class will be
declared readonly in TYPO3 v14.0 which will enforce instantiation
using PCPP. The class has been declared final since it is an API
contract that must never be changed or extended. The constructor
arguments will be declared non-optional in TYPO3 v14.0.

  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->setPageId()
  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->setTableName()
  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->setFieldName()
  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->setData()
  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->setPageTsConfig()
  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->getPageId()
  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->getTableName()
  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->getFieldName()
  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->getData()
  • TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext->getPageTsConfig()

Impact

Calling the getters or setters raises deprecation level log errors and
will stop working in TYPO3 v14.0.

Affected installations

This data object is only relevant for instances with extensions that add
custom backend layout data providers using
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['BackendLayoutDataProvider'].
There are few known extensions that do this. The extension scanner is
not configured to find possible usages since the method names are too
generic and would lead to too many false positives.

Migration

Create new objects using PCPP with named arguments instead of the
setters. Instances should be created using new():

// Before
$dataProviderContext = GeneralUtility::makeInstance(DataProviderContext::class);
$dataProviderContext
    ->setPageId($pageId)
    ->setData($parameters['row'])
    ->setTableName($parameters['table'])
    ->setFieldName($parameters['field'])
    ->setPageTsConfig($pageTsConfig);

// After
$dataProviderContext = new DataProviderContext(
    pageId: $pageId,
    tableName: $parameters['table'],
    fieldName: $parameters['field'],
    data: $parameters['row'],
    pageTsConfig: $pageTsConfig,
);

Use the properties instead of the getters, example:

// Before
$pageId = $dataProviderContext->getPageId()
// After
$pageId = $dataProviderContext->pageId

Backend, PHP-API, NotScanned, ext:backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant