Deprecation: #106393 - Various methods in BackendUtility
See forge#106393
Description
Due to the introduction of the Schema API, several methods of
\TYPO3\ that retrieve
information from
$GLOBALS have been deprecated:
BackendUtility:: get Common Select Fields () BackendUtility:: get Item Label () BackendUtility:: is Table Localizable () BackendUtility:: is Table Workspace Enabled () BackendUtility:: is Root Level Restriction Ignored () BackendUtility:: is Web Mount Restriction Ignored () BackendUtility:: resolve File References ()
Impact
Calling any of the mentioned methods now triggers a deprecation-level log entry and will stop working in TYPO3 v15.0.
The extension scanner reports usages as a strong match.
Affected installations
Instances or extensions that directly call these methods are affected.
Migration
The migration strategy is the same for all cases:
use the corresponding Schema API methods directly in your code.
In most cases, you'll need to inject
Tca via dependency injection.
getCommonSelectFields
No substitution is available. The method was marked as @internal already.
If your code depends on this functionality, copy the method into your own
extension.
getItemLabel
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Schema\TcaSchemaCapability;
use TYPO3\CMS\Core\Schema\TcaSchemaFactory;
// Before
return BackendUtility::getItemLabel('pages', 'title');
// After (retrieve an instance of TcaSchemaFactory via dependency
// injection of TYPO3\CMS\Core\Schema\TcaSchemaFactory)
$schema = $this->schemaFactory->has('pages')
? $this->schemaFactory->get('pages')
: null;
return $schema !== null && $schema->hasField('title')
? $schema->getField('title')->getLabel()
: null;
isTableLocalizable
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Schema\TcaSchemaCapability;
use TYPO3\CMS\Core\Schema\TcaSchemaFactory;
// Before
return BackendUtility::isTableLocalizable('pages');
// After (retrieve an instance of TcaSchemaFactory via dependency
// injection of TYPO3\CMS\Core\Schema\TcaSchemaFactory)
return $this->schemaFactory->has('pages')
&& $this->schemaFactory->get('pages')
->hasCapability(TcaSchemaCapability::Language);
isTableWorkspaceEnabled
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Schema\TcaSchemaCapability;
use TYPO3\CMS\Core\Schema\TcaSchemaFactory;
// Before
return BackendUtility::isTableWorkspaceEnabled('pages');
// After (retrieve an instance of TcaSchemaFactory via dependency
// injection of TYPO3\CMS\Core\Schema\TcaSchemaFactory)
return $this->schemaFactory->has('pages')
&& $this->schemaFactory->get('pages')
->hasCapability(TcaSchemaCapability::Workspace);
isRootLevelRestrictionIgnored
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Schema\TcaSchemaCapability;
use TYPO3\CMS\Core\Schema\TcaSchemaFactory;
// Before
return BackendUtility::isRootLevelRestrictionIgnored('pages');
// After (retrieve an instance of TcaSchemaFactory via dependency
// injection of TYPO3\CMS\Core\Schema\TcaSchemaFactory)
return $this->schemaFactory->has('pages')
&& $this->schemaFactory->get('pages')
->getCapability(
TcaSchemaCapability::RestrictionRootLevel
)->shallIgnoreRootLevelRestriction();
isWebMountRestrictionIgnored
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Schema\TcaSchemaCapability;
use TYPO3\CMS\Core\Schema\TcaSchemaFactory;
// Before
return BackendUtility::isWebMountRestrictionIgnored('pages');
// After (retrieve an instance of TcaSchemaFactory via dependency
// injection of TYPO3\CMS\Core\Schema\TcaSchemaFactory)
return $this->schemaFactory->has('pages')
&& $this->schemaFactory->get('pages')
->hasCapability(TcaSchemaCapability::RestrictionWebMount);
resolveFileReferences
No substitution is available. Copy the method into your own codebase and adapt it as needed.