entity_get_display()
and entity_get_form_display()
have been deprecated since before Drupal 8 was released. However, no replacements were ever developed for them despite their usefulness, which has forced core and contrib to rely on them.
#2367933: Move entity_get_(form_)display() to the entity display repository moves them into EntityDisplayRepository
, and they are both defined as methods of EntityDisplayRepositoryInterface
(implemented by the entity_display.repository
service and the deprecated entity.manager
service for backwards compatibility). Both functions are still around, and both are still deprecated, but they are now wrappers around the entity_display.repository
service.
Before:
entity_get_display('node', 'page', 'default');
entity_get_display('node', 'article', 'teaser');
entity_get_form_display('node', 'page', 'default');
After:
\Drupal::service('entity_display.repository')->getViewDisplay('node', 'page');
\Drupal::service('entity_display.repository')->getViewDisplay('node', 'article', 'teaser');
\Drupal::service('entity_display.repository')->getFormDisplay('node', 'page');