Deprecation: #96524 - Deprecate inline JavaScript in Dashboard

See forge#96524

Description

Using inline JavaScript when initializing RequireJS modules in individual dashboard widgets has been deprecated. Widget implementations have to be adjusted accordingly.

Impact

Usages will trigger PHP E_USER_DEPRECATED errors.

Affected Installations

Installations having individual widget implementations which are

  • implementing \TYPO3\CMS\Dashboard\Widgets\RequireJsModuleInterface
  • invoking \TYPO3\CMS\Dashboard\DashboardInitializationService->getRequireJsModules

Migration

Affected widget have to implement \TYPO3\CMS\Dashboard\Widgets\JavaScriptInterface instead of deprecated \TYPO3\CMS\Dashboard\Widgets\RequireJsModuleInterface. Instead of using inline JavaScript for initializing RequireJS modules, \TYPO3\CMS\Core\Page\JavaScriptModuleInstruction have to be declared.

class ExampleChartWidget implements RequireJsModuleInterface
{
    // ...
    public function getJavaScriptModuleInstructions(): array
    {
        return [
            'TYPO3/CMS/Dashboard/ChartInitializer' =>
                'function(ChartInitializer) { ChartInitializer.initialize(); }',
        ];
    }
}
Copied!

Deprecated example widget above would look like the following when using JavaScriptInterface and JavaScriptModuleInstruction:

class ExampleChartWidget implements JavaScriptInterface
{
    // ...
    public function getJavaScriptModuleInstructions(): array
    {
        return [
            JavaScriptModuleInstruction::forRequireJS(
                'TYPO3/CMS/Dashboard/ChartInitializer'
            )->invoke('initialize'),
        ];
    }
}
Copied!