Deprecation: #105252 - DataProviderContext getters and setters
See forge#105252
Description
The backend layout related data object class
\TYPO3\
has been turned into a data object using public constructor property promotion (PCPP).
All
set
and
get
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\ Backend Layout\ Data Provider Context->set Page Id () TYPO3\
CMS\ Backend\ View\ Backend Layout\ Data Provider Context->set Table Name () TYPO3\
CMS\ Backend\ View\ Backend Layout\ Data Provider Context->set Field Name () TYPO3\
CMS\ Backend\ View\ Backend Layout\ Data Provider Context->set Data () TYPO3\
CMS\ Backend\ View\ Backend Layout\ Data Provider Context->set Page Ts Config () TYPO3\
CMS\ Backend\ View\ Backend Layout\ Data Provider Context->get Page Id () TYPO3\
CMS\ Backend\ View\ Backend Layout\ Data Provider Context->get Table Name () TYPO3\
CMS\ Backend\ View\ Backend Layout\ Data Provider Context->get Field Name () TYPO3\
CMS\ Backend\ View\ Backend Layout\ Data Provider Context->get Data () TYPO3\
CMS\ Backend\ View\ Backend Layout\ Data Provider Context->get Page Ts Config ()
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
.
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