Skip to content

Deprecation Error Solutions

Dwayne McDaniel edited this page Mar 26, 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().

    *From https://www.drupal.org/node/3033656

     * Instead use to inject entity view builder handler into controller and call view() or viewMultiple()
       * Examples
    
       * 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 assertIdentical(), assertEqual(), assertNoText(), assertFieldByXPath(), of class Drupal\KernelTests\KernelTestBase.

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

    • @todo
  • 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