Download & Extend

entity_get_info() deprecated. Use Drupal::service('plugin.manager.entity')->getDefinitions()

Project: 
Drupal core
Introduced in branch: 
8.x
Description: 

Drupal 7

<?php
$allEntities
= entity_get_info();
$nodeEntity = entity_get_info('node');
?>

Drupal 8

<?php
/**
* Gets the entity definition for an entity type.
*
* @param string|null $entity_type
*   (optional) The entity type (e.g. 'node'). Leave NULL to retrieve
*   information for all entity types.
*
* @return array
*   An array containing the entity type's definition, as retrieved with
*   \Drupal\Core\Entity\EntityManager. If $entity_type is NULL, an associative
*   array of all entity type definitions keyed by entity type is returned.
*
* @see \Drupal\Core\Entity\EntityManager
* @see hook_entity_info_alter()
*/

$allEntities = Drupal::service('plugin.manager.entity')->getDefinitions();
$nodeEntity = Drupal::service('plugin.manager.entity')->getDefinition('node');
?>
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done

Comments

Is there an issue for this,

Is there an issue for this, because I still see the wrapper function in entity.inc. And, fwiw, I despise this change.

I didn`t find issue yet,

I didn`t find issue yet, possibly this needs @todo )
The entity_get_info() marked as deprecated in sources but there were no any change-records before this one

---------------
Andriy Podanenko
web(uk, ru, en)
personal blog(uk, ru)

fixed )

fixed )

---------------
Andriy Podanenko
web(uk, ru, en)
personal blog(uk, ru)

This notice is wrong

[edit]

I read the issue, and there is nothing relevant to marking this function as deprecated. I don't understand this change notice. Removing entity_get_info() in this manner is horrible DX. You are ripping out an API function for an obscure chained method.

Why would we do that? We didn't deprecate entity_create().

#1892462-16: Change record:

---------------
Andriy Podanenko
web(uk, ru, en)
personal blog(uk, ru)