Skip to content

Deprecation Error Solutions

Joseph D. Purcell edited this page Apr 4, 2019 · 11 revisions
  • drupal_set_message

    • \Drupal::service('messenger')->addMessage(....) is a replacement for drupal_set_message in .module files, but in classes, the messenger service should be injected.
    • For any form class that inherits FormBase (or any other class that inherits MessengerTrait), replace drupal_set_message with $this->messenger->addMessage
    • Use method addError for drupal_set_message(..., ‘error’), addWarning for drupal_set_message(..., ‘warning’), etc. See the API docs
  • Call to deprecated function entity_view().

    • Use the entity type manager instead. See https://www.drupal.org/node/3033656 for details.
      • Before

        $build = entity_view($node, 'teaser')
        
      • After

        $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); 
        $build = $builder->view($node, 'teaser');
        
  • Call to deprecated function entity_get_display().

  • Call to deprecated function entity_get_form_display().

  • Call to deprecated method [METHOD NAME] of class Drupal\KernelTests\KernelTestBase.

  • Call to method [METHOD NAME] of deprecated class Drupal\Tests\BrowserTestBase.

  • Class [CLASS NAME] not found and could not be autoloaded.

    • @todo
  • Usage of deprecated trait [CLASS NAME] in class [CLASS NAME]

    • @todo
Clone this wiki locally