diff --git a/core/includes/entity.inc b/core/includes/entity.inc index b3220f3..46abd5e 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -39,6 +39,12 @@ function entity_render_cache_clear() { * @see \Drupal\Core\Entity\EntityManagerInterface::getBundleInfo() * @see \Drupal\Core\Entity\EntityManagerInterface::getAllBundleInfo() */ + * + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use the + * \Drupal::entityManager()->getBundleInfo($entity_type) to get the info of a + * known entity type and use \Drupal::entityManager()->getAllBundleInfo() for + * all bundles. + */ function entity_get_bundles($entity_type = NULL) { if (isset($entity_type)) { return \Drupal::entityManager()->getBundleInfo($entity_type); @@ -65,6 +71,11 @@ function entity_get_bundles($entity_type = NULL) { * @see \Drupal\Core\Entity\EntityStorageInterface * @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage * @see \Drupal\Core\Entity\Query\QueryInterface + * + * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * the ::load($id) method if the entity type is known or + * \Drupal::entityManager()->getStorage($entity_type)->load($id) if the + * entity type is variable. */ function entity_load($entity_type, $id, $reset = FALSE) { $controller = \Drupal::entityManager()->getStorage($entity_type); @@ -89,6 +100,9 @@ function entity_load($entity_type, $id, $reset = FALSE) { * @see \Drupal\Core\Entity\EntityManagerInterface * @see \Drupal\Core\Entity\EntityStorageInterface * @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage + * + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * \Drupal::entityManager()->getStorage($entity_type)->loadRevision($revision_id); */ function entity_revision_load($entity_type, $revision_id) { return \Drupal::entityManager() @@ -103,7 +117,11 @@ function entity_revision_load($entity_type, $revision_id) { * The entity type to load, e.g. node or user. * @param $revision_id * The revision ID to delete. + * + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * \Drupal::entityManager()>getStorage($entity_type)>deleteRevision($revision_id); */ + function entity_revision_delete($entity_type, $revision_id) { \Drupal::entityManager() ->getStorage($entity_type) @@ -142,6 +160,11 @@ function entity_revision_delete($entity_type, $revision_id) { * @see \Drupal\Core\Entity\EntityManagerInterface * @see \Drupal\Core\Entity\EntityStorageInterface * @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage + * + * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * the ::loadMultiple($ids) method if the entity type is known or + * \Drupal::entityManager()->getStorage($entity_type)->loadMultiple($ids) if + * the entity type is variable. * @see \Drupal\Core\Entity\Query\QueryInterface */ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { @@ -164,6 +187,9 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { * @return array * An array of entity objects indexed by their IDs. Returns an empty array if * no matching entities are found. + * + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * \Drupal::entityManager()->getStorage($entity_type)->loadByProperties($values); */ function entity_load_multiple_by_properties($entity_type, array $values) { return \Drupal::entityManager() @@ -186,6 +212,8 @@ function entity_load_multiple_by_properties($entity_type, array $values) { * * @return * The unchanged entity, or FALSE if the entity cannot be loaded. + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * \Drupal::entityManager()->getStorage($entity_type)->loadUnchanged($id). */ function entity_load_unchanged($entity_type, $id) { return \Drupal::entityManager() @@ -200,6 +228,11 @@ function entity_load_unchanged($entity_type, $id) { * The type of the entity. * @param array $ids * An array of entity IDs of the entities to delete. + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * EntityManager loadMultiple Method to delete multiple entities + * $storage_handler = \Drupal::entityManager()->getStorage($entity_type); + * $entities = $storage_handler->loadMultiple($ids); + * $storage_handler->delete($entities); */ function entity_delete_multiple($entity_type, array $ids) { $controller = \Drupal::entityManager()->getStorage($entity_type); @@ -218,11 +251,10 @@ function entity_delete_multiple($entity_type, array $ids) { * * @return \Drupal\Core\Entity\EntityInterface * A new entity object. - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0.0. Use - * the ::create($values) method if the entity type is known or - * \Drupal::entityManager()->getStorage($entity_type)->create($values) if the - * entity type is variable. + * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. + * Use the ::create($values) method if the entity type is known + * or \Drupal::entityManager()->getStorage($entity_type)->create($values) if + * the entity type is variable. */ function entity_create($entity_type, array $values = array()) { return \Drupal::entityManager() @@ -233,8 +265,8 @@ function entity_create($entity_type, array $values = array()) { /** * Returns the label of an entity. * - * This is a wrapper for Drupal\Core\Entity\EntityInterface::label(). This function - * should only be used as a callback, e.g. for menu title callbacks. + * This is a wrapper for Drupal\Core\Entity\EntityInterface::label(). This + * function should only be used as a callback, e.g. for menu title callbacks. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity for which to generate the label. @@ -247,6 +279,8 @@ function entity_create($entity_type, array $values = array()) { * The label of the entity, or NULL if there is no label defined. * * @see \Drupal\Core\Entity\EntityInterface::label() + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. + * Use $entity->label($langcode); */ function entity_page_label(EntityInterface $entity, $langcode = NULL) { return $entity->label($langcode); @@ -268,6 +302,12 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) { * * @return array * A render array for the entity. + * + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. + * Use Entity Manager view method for it after building the entity view using + * getViewBuilder method. + * $view_builder = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId()); + * return $view_builder->view($entity, $view_mode, $langcode); */ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) { $render_controller = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId()); @@ -294,6 +334,11 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res * @return array * A render array for the entities, indexed by the same keys as the * entities array passed in $entities. + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. + * Use Entity Manager viewMultiple method for it after building the entity + * view using getViewBuilder method. + * $view_builder = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId()); + * return $view_builder->viewMultiple($entities, $view_mode, $langcode); */ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) { $render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->getEntityTypeId()); @@ -341,6 +386,17 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $re * * @return \Drupal\Core\Entity\Display\EntityViewDisplayInterface * The entity view display associated to the view mode. + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. + * If display is available in configuration then use : + * \Drupal::entityManager()->getStorage('entity_view_display')->load($entity_type . '.' . $bundle . '.' . $view_mode); + * else use: + * $values = ('entity_view_display', array( + * 'targetEntityType' => $entity_type, + * 'bundle' => $bundle, + * 'mode' => $view_mode, + * 'status' => TRUE, + * )); + * \Drupal::entityManager()->getStorage('entity_view_display')->create($values); */ function entity_get_display($entity_type, $bundle, $view_mode) { // Try loading the display from configuration. @@ -397,6 +453,17 @@ function entity_get_display($entity_type, $bundle, $view_mode) { * * @return \Drupal\Core\Entity\Display\EntityFormDisplayInterface * The entity form display associated to the given form mode. + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * If display is available in configuration then use : + * \Drupal::entityManager()->getStorage('entity_form_display')->load($entity_type . '.' . $bundle . '.' . $form_mode); + * else use: + * $values = ('entity_form_display', array( + * 'targetEntityType' => $entity_type, + * 'bundle' => $bundle, + * 'mode' => $form_mode, + * 'status' => TRUE, + * )); + * \Drupal::entityManager()->getStorage('entity_form_display')->create($values); */ function entity_get_form_display($entity_type, $bundle, $form_mode) { // Try loading the entity from configuration.