My website is running TYPO3 v12.
I want to create a very simple widget in order to display a text in the dashboard. I read and follow this tutorial and the official Typo3 dashboard doc but I get error 500.
ClassesWidgetCustomWidget.php
<code><?php
class CustomWidget implements WidgetInterface
{
/**
* @var WidgetConfigurationInterface
*/
private $configuration;
/**
* @var StandaloneView
*/
private $view;
/**
* @var Cache
*/
private $cache;
/**
* @var array
*/
private $options;
/**
* @var ButtonProviderInterface|null
*/
private $buttonProvider;
public function __construct(
WidgetConfigurationInterface $configuration,
Cache $cache,
StandaloneView $view,
ButtonProviderInterface $buttonProvider = null,
array $options = []
) {
$this->configuration = $configuration;
$this->view = $view;
$this->cache = $cache;
$this->buttonProvider = $buttonProvider;
}
public function renderWidgetContent(): string
{
$this->view->setTemplate('Widget/CustomWidget');
$this->view->assignMultiple([
'items' => 'Wow! Looks Amazing Widget!',
'button' => $this->getButton(),
'configuration' => $this->configuration,
]);
return $this->view->render();
}
}
</code>
<code><?php
class CustomWidget implements WidgetInterface
{
/**
* @var WidgetConfigurationInterface
*/
private $configuration;
/**
* @var StandaloneView
*/
private $view;
/**
* @var Cache
*/
private $cache;
/**
* @var array
*/
private $options;
/**
* @var ButtonProviderInterface|null
*/
private $buttonProvider;
public function __construct(
WidgetConfigurationInterface $configuration,
Cache $cache,
StandaloneView $view,
ButtonProviderInterface $buttonProvider = null,
array $options = []
) {
$this->configuration = $configuration;
$this->view = $view;
$this->cache = $cache;
$this->buttonProvider = $buttonProvider;
}
public function renderWidgetContent(): string
{
$this->view->setTemplate('Widget/CustomWidget');
$this->view->assignMultiple([
'items' => 'Wow! Looks Amazing Widget!',
'button' => $this->getButton(),
'configuration' => $this->configuration,
]);
return $this->view->render();
}
}
</code>
<?php
class CustomWidget implements WidgetInterface
{
/**
* @var WidgetConfigurationInterface
*/
private $configuration;
/**
* @var StandaloneView
*/
private $view;
/**
* @var Cache
*/
private $cache;
/**
* @var array
*/
private $options;
/**
* @var ButtonProviderInterface|null
*/
private $buttonProvider;
public function __construct(
WidgetConfigurationInterface $configuration,
Cache $cache,
StandaloneView $view,
ButtonProviderInterface $buttonProvider = null,
array $options = []
) {
$this->configuration = $configuration;
$this->view = $view;
$this->cache = $cache;
$this->buttonProvider = $buttonProvider;
}
public function renderWidgetContent(): string
{
$this->view->setTemplate('Widget/CustomWidget');
$this->view->assignMultiple([
'items' => 'Wow! Looks Amazing Widget!',
'button' => $this->getButton(),
'configuration' => $this->configuration,
]);
return $this->view->render();
}
}
ConfigurationServices.yaml
<code>services:
_defaults:
autowire: true
autoconfigure: true
public: false
MyCompany:
resource: '../Classes/*'
TYPO3CMSDashboardWidgets:
resource: '../Classes/Widgets/*'
dashboard.buttons.custom:
class: 'TYPO3CMSDashboardWidgetsProviderButtonProvider'
arguments:
$title: 'Custom Widget'
$link: 'https://t3planet.com/'
$target: '_blank'
dashboard.widget.custom:
class: 'MyCompanyWidgetCustomWidget'
arguments:
$view: '@dashboard.views.widget'
$buttonProvider: '@dashboard.buttons.custom'
$cache: '@cache.dashboard.rss'
tags:
- name: dashboard.widget
identifier: 'custom'
groupNames: 'general'
title: 'Custom Widget'
description: 'Wow! Looks Amazing Widget!'
iconIdentifier: 'content-widget-rss'
height: 'medium'
width: 'medium'
</code>
<code>services:
_defaults:
autowire: true
autoconfigure: true
public: false
MyCompany:
resource: '../Classes/*'
TYPO3CMSDashboardWidgets:
resource: '../Classes/Widgets/*'
dashboard.buttons.custom:
class: 'TYPO3CMSDashboardWidgetsProviderButtonProvider'
arguments:
$title: 'Custom Widget'
$link: 'https://t3planet.com/'
$target: '_blank'
dashboard.widget.custom:
class: 'MyCompanyWidgetCustomWidget'
arguments:
$view: '@dashboard.views.widget'
$buttonProvider: '@dashboard.buttons.custom'
$cache: '@cache.dashboard.rss'
tags:
- name: dashboard.widget
identifier: 'custom'
groupNames: 'general'
title: 'Custom Widget'
description: 'Wow! Looks Amazing Widget!'
iconIdentifier: 'content-widget-rss'
height: 'medium'
width: 'medium'
</code>
services:
_defaults:
autowire: true
autoconfigure: true
public: false
MyCompany:
resource: '../Classes/*'
TYPO3CMSDashboardWidgets:
resource: '../Classes/Widgets/*'
dashboard.buttons.custom:
class: 'TYPO3CMSDashboardWidgetsProviderButtonProvider'
arguments:
$title: 'Custom Widget'
$link: 'https://t3planet.com/'
$target: '_blank'
dashboard.widget.custom:
class: 'MyCompanyWidgetCustomWidget'
arguments:
$view: '@dashboard.views.widget'
$buttonProvider: '@dashboard.buttons.custom'
$cache: '@cache.dashboard.rss'
tags:
- name: dashboard.widget
identifier: 'custom'
groupNames: 'general'
title: 'Custom Widget'
description: 'Wow! Looks Amazing Widget!'
iconIdentifier: 'content-widget-rss'
height: 'medium'
width: 'medium'
When saving my xxx, TYPO3 front-end + back-end are broken with error 500.
My php_error.log (from WAMP) has this error:
<code>PHP Fatal error: Uncaught Error: Typed static property TYPO3CMSCoreUtilityExtensionManagementUtility::$packageManager must not be accessed before initialization in C:wamp64wwwmycompanyvendortypo3cms-coreClassesUtilityExtensionManagementUtility.php:111
</code>
<code>PHP Fatal error: Uncaught Error: Typed static property TYPO3CMSCoreUtilityExtensionManagementUtility::$packageManager must not be accessed before initialization in C:wamp64wwwmycompanyvendortypo3cms-coreClassesUtilityExtensionManagementUtility.php:111
</code>
PHP Fatal error: Uncaught Error: Typed static property TYPO3CMSCoreUtilityExtensionManagementUtility::$packageManager must not be accessed before initialization in C:wamp64wwwmycompanyvendortypo3cms-coreClassesUtilityExtensionManagementUtility.php:111
I tried to create the widget without buttons and with minimal requirements, same error.