diff --git a/core/modules/layout_builder/src/Element/LayoutBuilder.php b/core/modules/layout_builder/src/Element/LayoutBuilder.php index 05f4d5a06e..dd65f05aa1 100644 --- a/core/modules/layout_builder/src/Element/LayoutBuilder.php +++ b/core/modules/layout_builder/src/Element/LayoutBuilder.php @@ -5,6 +5,7 @@ use Drupal\Component\Plugin\DerivativeInspectionInterface; use Drupal\Core\Ajax\AjaxHelperTrait; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Render\Element; @@ -59,17 +60,14 @@ class LayoutBuilder extends RenderElement implements ContainerFactoryPluginInter * The plugin implementation definition. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher service. - * @param \Drupal\Core\Messenger\MessengerInterface|null $messenger - * The messenger service. This is no longer used and will be removed in - * drupal:10.0.0. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * @param \Drupal\Core\Messenger\MessengerInterface|\Drupal\Core\Entity\EntityTypeManagerInterface|null $entity_type_manager * (optional) The entity type manager. * * @todo The current constructor signature is deprecated: * - The $entity_type_manager parameter is optional but should become * required. Deprecate in https://www.drupal.org/node/3058490. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, $event_dispatcher, $messenger = NULL, EntityTypeManagerInterface $entity_type_manager = NULL) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, $event_dispatcher, $entity_type_manager = NULL) { parent::__construct($configuration, $plugin_id, $plugin_definition); if (!($event_dispatcher instanceof EventDispatcherInterface)) { @@ -78,11 +76,11 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition } $this->eventDispatcher = $event_dispatcher; - if ($messenger) { + if ($entity_type_manager instanceof MessengerInterface) { @trigger_error('Calling LayoutBuilder::__construct() with the $messenger argument is deprecated in drupal:9.1.0 and will be removed in drupal:10.0.0. See https://www.drupal.org/node/3152690', E_USER_DEPRECATED); } - if ($entity_type_manager === NULL) { + if ($entity_type_manager === NULL || !$entity_type_manager instanceof EntityTypeManagerInterface) { @trigger_error('The entity_type.manager service must be passed to \Drupal\layout_builder\Element\LayoutBuilder::__construct(). It was added in Drupal 8.8.0 and will be required before Drupal 9.0.0.', E_USER_DEPRECATED); $entity_type_manager = \Drupal::service('entity_type.manager'); }