diff --git a/core/lib/Drupal/Core/Render/Annotation/RenderElement.php b/core/lib/Drupal/Core/Render/Annotation/RenderElement.php index caf17aefcc..82fa476922 100644 --- a/core/lib/Drupal/Core/Render/Annotation/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Annotation/RenderElement.php @@ -26,4 +26,18 @@ */ class RenderElement extends PluginID { + /** + * The plugin ID. + * + * @var string + */ + public $id; + + /** + * A boolean stating that plugins of this type are deprecated. + * + * @var bool + */ + public $deprecated; + } diff --git a/core/lib/Drupal/Core/Render/Element/Ajax.php b/core/lib/Drupal/Core/Render/Element/Ajax.php index 0e72f064f9..6acff0b469 100644 --- a/core/lib/Drupal/Core/Render/Element/Ajax.php +++ b/core/lib/Drupal/Core/Render/Element/Ajax.php @@ -5,15 +5,19 @@ /** * Provides a render element for adding Ajax to a render element. * - * @deprecated in Drupal 8.8.x and is removed from Drupal 9.0.0. + * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use + * \Drupal\Core\Ajax\AjaxResponse instead. * * Holds an array whose values control the Ajax behavior of the element. * * @ingroup ajax * - * @RenderElement("ajax") + * @RenderElement( + * id = "ajax", + * deprecated = TRUE, + * ) * - * @see https://www.drupal.org/project/drupal/issues/3067580 + * @see https://www.drupal.org/node/3068104 */ class Ajax extends RenderElement { @@ -22,7 +26,7 @@ class Ajax extends RenderElement { */ public function __construct(array $configuration, $plugin_id, $plugin_definition) { parent::__construct($configuration, $plugin_id, $plugin_definition); - @trigger_error('\Drupal\Core\Render\Element\Ajax is deprecated in Drupal 8.8.x and is removed from Drupal 9.0.0.', E_USER_DEPRECATED); + @trigger_error('\Drupal\Core\Render\Element\Ajax is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Ajax\AjaxResponse instead. See https://www.drupal.org/node/3068104', E_USER_DEPRECATED); } /** diff --git a/core/lib/Drupal/Core/Render/ElementInfoManager.php b/core/lib/Drupal/Core/Render/ElementInfoManager.php index 015e3900bd..bbbb74639e 100644 --- a/core/lib/Drupal/Core/Render/ElementInfoManager.php +++ b/core/lib/Drupal/Core/Render/ElementInfoManager.php @@ -131,6 +131,17 @@ protected function buildInfo($theme_name) { return $info; } + /** + * {@inheritdoc} + */ + protected function findDefinitions() { + $definitions = parent::findDefinitions(); + // Filter out definitions that deprecated. + return array_filter($definitions, function ($definition) { + return !empty($definition['deprecated']); + }); + } + /** * {@inheritdoc} *