Rename RenderElement and FormElement plugin abstract classes to RenderElementBase and FormElementBase

Created on 18 March 2024, 8 months ago
Updated 4 August 2024, 3 months ago

Problem/Motivation

After moving RenderElement and FormElement plugin discovery from annotations to attributes in πŸ“Œ Convert form and render element plugin discovery to attributes Active , it has often become necessary in many element plugin implementation to import "RenderElement" or "FormElement" classes from two different namespaces for each plugin type:

  1. \Drupal\Core\Render\Element\RenderElement and \Drupal\Core\Render\Attribute\RenderElement
  2. \Drupal\Core\Render\Element\FormElement and \Drupal\Core\Render\Attribute\FormElement

This can have a negative impact on developer experience, because IDEs such as PHPStorm often do not provide typehint/autocomplete for the class name if a use statement was already added,or if the referenced class exists in the same namespace as the current one.

Additionally, \Drupal\Core\Render\Element\RenderElement and\Drupal\Core\Render\Element\FormElement are abstract classes, and there is convention in adding a "Base" suffix to these types of classes.

Suggestion here is to call these classes RenderElementBase and FormElementBase.

Steps to reproduce

Proposed resolution

  1. Create abstract class \Drupal\Core\Render\Element\RenderElementBase and move all the contents of \Drupal\Core\Render\Element\RenderElement there
  2. to Create abstract class \Drupal\Core\Render\Element\FormElementBase and move all the contents of \Drupal\Core\Render\Element\FormElement there
  3. Set \Drupal\Core\Render\Element\RenderElement to extend \Drupal\Core\Render\Element\RenderElementBase
  4. Set \Drupal\Core\Render\Element\FormElement to extend \Drupal\Core\Render\Element\FormElementBase
  5. Add deprecation messages for \Drupal\Core\Render\Element\RenderElement and \Drupal\Core\Render\Element\FormElement
  6. Add CR

Remaining tasks

User interface changes

API changes

  1. \Drupal\Core\Render\Element\RenderElement renamed to \Drupal\Core\Render\Element\RenderElementBase
  2. \Drupal\Core\Render\Element\FormElement renamed to \Drupal\Core\Render\Element\FormElementBase

No other changes

Data model changes

N/a

Release notes snippet

As this is a simple rename with the API left in place to Drupal 12 I don't think this warrants a release note.

πŸ“Œ Task
Status

Fixed

Version

10.3 ✨

Component
BaseΒ  β†’

Last updated about 3 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024