By podarok on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
Drupal 7
$allEntities = entity_get_info();
$nodeEntity = entity_get_info('node');
Drupal 8
/**
* 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\EntityManagerInterface. If $entity_type is NULL, an
* associative array of all entity type definitions keyed by entity type is
* returned.
*
* @see \Drupal\Core\Entity\EntityManagerInterface
* @see hook_entity_info_alter()
*/
$allEntities = \Drupal::entityTypeManager()->getDefinitions();
$nodeEntity = \Drupal::entityTypeManager()->getDefinition('node');
Impacts:
Module developers
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
---------------
Andrii Podanenko
CEO, ITCare
fixed )
fixed )
---------------
Andrii Podanenko
CEO, ITCare
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:
#1892462-16: EntityManager should use the CacheDecorator patch commits @deprecated
---------------
Andrii Podanenko
CEO, ITCare
To get the old array dataset
Use code like
(See discussion in #2304863: EntityType should support toArray())
Drupal::entityManager() is
Drupal::entityManager()is deprecated and so isEntityManager:display using drush
If you want to output a list of entities in D8 with Drush try:
drush ev "print_r(array_keys(\Drupal::entityTypeManager()->getDefinitions()));"Or a specific entity's definition like moderation_state, try:
drush ev "print_r(\Drupal::entityTypeManager()->getDefinition('moderation_state'));