Problem/Motivation

Follow-up from #2311393-46: Remove hook_element_info() and all references to it where @jhodgdon says:

It is too late to remove a hook at this point in the development cycle.

However, we still need parts of the patch... I suppose we need to open yet another issue to update the docs. for instance:

+++ b/core/includes/common.inc
@@ -1196,7 +1196,7 @@ function show(&$element) {
  * Retrieves the default properties for the defined element type.
  *
  * @param $type
- *   An element type as defined by hook_element_info().
+ *   An element type as defined by an element plugin.

This needs to say "hook_element_info() or an element plugin". And there are numerous other spots from the current patch.

Proposed resolution

Update the documentation

Remaining tasks

Patch
Reviews
Commit

User interface changes

None

API changes

None

Data model changes

None

Comments

almaudoh created an issue. See original summary.

mile23’s picture

hook_element_info() is going to be deprecated for D9: #2556935: Deprecate hook_element_info() for Drupal 8.0.0

almaudoh’s picture

Status: Active » Needs review
StatusFileSize
new13.02 KB

Took the patch from #2311393-34: Remove hook_element_info() and all references to it and removed all non-docs changes to get this patch.

almaudoh’s picture

StatusFileSize
new5.42 KB
new9.04 KB

Missed out quite a lot, caused by a bad rebase:

  1. +++ b/core/includes/common.inc
    @@ -1213,7 +1213,7 @@ function element_info($type) {
    - *   An element type as defined by hook_element_info().
    + *   An element type as defined by an element plugin.
    

    Missed one.

  2. +++ b/core/lib/Drupal/Core/Render/ElementInfoManager.php
    @@ -110,10 +110,7 @@ protected function buildInfo($theme_name) {
    -    // @todo Remove this hook once all elements are converted to plugins in
    -    //   https://www.drupal.org/node/2311393.
    -    $info = $this->moduleHandler->invokeAll('element_info');
    -
    +    $info = [];
    

    Missed this too...

  3. +++ b/core/lib/Drupal/Core/Render/ElementInfoManagerInterface.php
    @@ -44,8 +44,6 @@
    -   * @see hook_element_info()
    -   * @see hook_element_info_alter()
    

    And these

  4. +++ b/core/lib/Drupal/Core/Render/theme.api.php
    @@ -691,32 +689,6 @@ function hook_render_template($template_file, $variables) {
    - * Allows modules to declare their own Form API element types and specify their
    - * default values.
    - *
    - * This hook allows modules to declare their own form element types and to
    - * specify their default values. The values returned by this hook will be
    - * merged with the elements returned by form constructor implementations and so
    - * can return defaults for any Form APIs keys in addition to those explicitly
    - * documented by \Drupal\Core\Render\ElementInfoManagerInterface::getInfo().
    - *
    - * @return array
    - *   An associative array with structure identical to that of the return value
    - *   of \Drupal\Core\Render\ElementInfoManagerInterface::getInfo().
    - *
    - * @deprecated Use an annotated class instead, see
    - *   \Drupal\Core\Render\Element\ElementInterface.
    - *
    - * @see hook_element_info_alter()
    - */
    -function hook_element_info() {
    -  $types['filter_format'] = array(
    -    '#input' => TRUE,
    -  );
    -  return $types;
    -}
    -
    -/**
    

    Oops ;p

Also reverted the test coverage removal.

tim.plunkett’s picture

I might as well get credit for this, as it's my patch you're chopping up :)

jhodgdon’s picture

Status: Needs review » Needs work

Pretty close, thanks! (And @tim.plunkett I have added you to the commit credit.)

A few things to fix:

  1. +++ b/core/lib/Drupal/Core/Render/theme.api.php
    @@ -294,10 +294,8 @@
    + * Modules can define render elements by defining an element plugin or by
    + * implementing hook_element_info(), however, hook_element_info() is deprecated.
      *
    

    The first comma in the 2nd line should be a ; instead.

  2. +++ b/core/lib/Drupal/Core/Render/theme.api.php
    @@ -294,10 +294,8 @@
    + * implementing hook_element_info(), however, hook_element_info() is deprecated.
    

    The first comma in this line should be a ; instead

  3. +++ b/core/lib/Drupal/Core/Render/theme.api.php
    @@ -691,32 +689,6 @@ function hook_render_template($template_file, $variables) {
    -function hook_element_info() {
    

    We should not be removing the hook_element_info() documentation here. The other issue is marking it deprecated.

  4. +++ b/core/lib/Drupal/Core/Render/theme.api.php
    - * @see hook_element_info()
    + * @see \Drupal\Core\Render\ElementInfoManager
    + * @see \Drupal\Core\Render\Element\ElementInterface
      */
     function hook_element_info_alter(array &$types) {
    

    Let's not take out the existing @see to hook_element_info() here either.

  5. +++ b/core/modules/contextual/contextual.api.php
    @@ -29,7 +29,6 @@
    - * @see contextual_element_info()
    

    Presumably this has been replaced by an element that should be referenced in place of the hook implementation?

  6. +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
    @@ -678,9 +678,6 @@ public function multistepAjax($form, FormStateInterface $form_state) {
    -   * This function is assigned as a #pre_render callback in
    -   * field_ui_element_info().
    -   *
        * @param array $elements
    

    We should replace this with something else? Presumably this is now assigned as a pre-render callback somewhere else?

  7. +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
    @@ -688,6 +685,8 @@ public function multistepAjax($form, FormStateInterface $form_state) {
    +   * @return array
    +   *
        * @see drupal_render()
    

    If we area adding @return array, we also need to document what this returns.

tim.plunkett’s picture

Status: Needs work » Closed (duplicate)