Breaking: #96333 - Auto configuration of ContextMenu item providers
See forge#96333
Description
ContextMenu item providers, implementing \TYPO3\
are now automatically registered by adding the backend.
tag, if autoconfigure
is enabled in Services.
. The new
\TYPO3\
then
automatically receives those services and registers them.
All Core item providers extend the Abstract
class, which is
usually also used by extensions. Due to the auto configuration, the context
information (table, record identifier and context) is no longer passed to the
__
, but instead to the new set
method.
The set
method is therefore required for all item providers.
Impact
The registration via $GLOBALS
isn't evaluated anymore.
The item providers are retrieved from the container and are no longer
instantiated while passing context information as constructor arguments.
The context information is now passed to set
.
Affected Installations
All extensions, registering custom ContextMenu item providers.
All extensions, extending Abstract
and overwriting the
__
method.
All extensions, not extending Abstract
, but implementing
\TYPO3\
directly.
Migration
Remove $GLOBALS
from your ext_
file. If autoconfigure
is
not enabled in your Configuration/
file,
manually configure your item providers with the
backend.
tag.
If your item providers extend Abstract
and overwrite the
__
method, adjust the signature like shown below:
// Before
class MyItemProvider extends AbstractProvider {
public function __construct(string $table, string $identifier, string $context = '')
{
parent::__construct($table, $identifier, $context);
// My custom code
}
}
// After
class MyItemProvider extends AbstractProvider {
public function __construct()
{
parent::__construct();
// My custom code
}
}
In case you rely on the arguments, previously passed to __
,
you can override the new set
method, which is executed
prior to any other action like can
.
// Before
class MyItemProvider extends AbstractProvider {
public function __construct(string $table, string $identifier, string $context = '')
{
parent::__construct($table, $identifier, $context);
if ($table === 'my_table') {
// Do something
}
}
// After
class MyItemProvider extends AbstractProvider {
public function setContext(string $table, string $identifier, string $context = ''): void
{
parent::setContext($table, $identifier, $context);
if ($table === 'my_table') {
// Do something
}
}
}
In case your item provider does not extend Abstract
, but instead
implements the \TYPO3\
directly, add the new set
to the item provider.