diff -u b/core/includes/entity.inc b/core/includes/entity.inc --- b/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -62,12 +62,17 @@ * The entity object, or NULL if there is no entity with the given ID. * * @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. - * - * @see \Drupal\Core\Entity\EntityManagerInterface - * @see \Drupal\Core\Entity\EntityStorageInterface + * The method overriding Entity::load() for the entity type, e.g. + * \Drupal\node\Entity\Node::load() if the entity type is known. If the + * entity type is variable, use the entity manager service to load the entity + * from the entity storage: + * @code + * \Drupal::entityManager()->getStorage($entity_type)->load($id) + * @endcode + * + * @see \Drupal\Core\Entity\EntityInterface::load() + * @see \Drupal\Core\Entity\EntityManagerInterface::getStorage() + * @see \Drupal\Core\Entity\EntityStorageInterface::load() * @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage * @see \Drupal\Core\Entity\Query\QueryInterface */ @@ -92,10 +97,14 @@ * id. * * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * the entity storage's loadRevision method to load a specific entity + * revision: + * @code * \Drupal::entityManager()->getStorage($entity_type)->loadRevision($revision_id); + * @endcode * - * @see \Drupal\Core\Entity\EntityManagerInterface - * @see \Drupal\Core\Entity\EntityStorageInterface + * @see \Drupal\Core\Entity\EntityManagerInterface::getStorage() + * @see \Drupal\Core\Entity\EntityStorageInterface::loadRevision() * @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage */ function entity_revision_load($entity_type, $revision_id) { @@ -113,7 +122,14 @@ * 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); + * the entity storage's deleteRevision method to delete a specific entity + * revision: + * @code + * \Drupal::entityManager()->getStorage($entity_type)>deleteRevision($revision_id); + * @endcode + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getStorage() + * @see \Drupal\Core\Entity\EntityStorageInterface::deleteRevision() */ function entity_revision_delete($entity_type, $revision_id) { \Drupal::entityManager() @@ -151,12 +167,17 @@ * An array of entity objects indexed by their IDs. * * @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\EntityManagerInterface - * @see \Drupal\Core\Entity\EntityStorageInterface + * The method overriding Entity::loadMultiple() for the entity type, e.g. + * \Drupal\node\Entity\Node::loadMultiple() if the entity type is known. If + * the entity type is variable, use the entity manager service to load the + * entity from the entity storage: + * @code + * \Drupal::entityManager()->getStorage($entity_type)->loadMultiple($id) + * @endcode + * + * @see \Drupal\Core\Entity\EntityInterface::loadMultiple() + * @see \Drupal\Core\Entity\EntityManagerInterface::getStorage() + * @see \Drupal\Core\Entity\EntityStorageInterface::loadMultiple() * @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage * @see \Drupal\Core\Entity\Query\QueryInterface */ @@ -182,7 +203,11 @@ * no matching entities are found. * * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * the * \Drupal::entityManager()->getStorage($entity_type)->loadByProperties($values); + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getStorage() + * @see \Drupal\Core\Entity\EntityStorageInterface::loadByProperties() */ function entity_load_multiple_by_properties($entity_type, array $values) { return \Drupal::entityManager() @@ -203,11 +228,14 @@ * @param $id * The ID of the entity to load. * - * @return + * @return \Drupal\Core\Entity\EntityInterface|null * 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). + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getStorage() + * @see \Drupal\Core\Entity\EntityStorageInterface::loadUnchanged() */ function entity_load_unchanged($entity_type, $id) { return \Drupal::entityManager() @@ -224,10 +252,16 @@ * 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 + * the entity storage's delete method to delete multiple entities: + * @code * $storage_handler = \Drupal::entityManager()->getStorage($entity_type); * $entities = $storage_handler->loadMultiple($ids); * $storage_handler->delete($entities); + * @endcode + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getStorage() + * @see \Drupal\Core\Entity\EntityStorageInterface::loadMultiple() + * @see \Drupal\Core\Entity\EntityStorageInterface::delete() */ function entity_delete_multiple($entity_type, array $ids) { $controller = \Drupal::entityManager()->getStorage($entity_type); @@ -247,10 +281,17 @@ * @return \Drupal\Core\Entity\EntityInterface * A new entity object. * - * @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. + * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * The method overriding Entity::create() for the entity type, e.g. + * \Drupal\node\Entity\Node::create() if the entity type is known. If the + * entity type is variable, use the entity storage's create method to + * construct a new entity: + * @code + * \Drupal::entityManager()->getStorage($entity_type)->create($values) + * @endcode + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getStorage() + * @see \Drupal\Core\Entity\EntityStorageInterface::create() */ function entity_create($entity_type, array $values = array()) { return \Drupal::entityManager() @@ -261,9 +302,6 @@ /** * 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. - * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity for which to generate the label. * @param $langcode @@ -271,11 +309,14 @@ * getting the label. If set to NULL, the entity's default language is * used. * - * @return + * @return string|null * The label of the entity, or NULL if there is no label defined. * - * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use + * the entity's label method to get the label of the entity: + * @code * Use $entity->label($langcode); + * @endcode * * @see \Drupal\Core\Entity\EntityInterface::label() */ @@ -301,10 +342,14 @@ * 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. + * Use the entity view builder's view method for creating a render array: + * @code * $view_builder = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId()); * return $view_builder->view($entity, $view_mode, $langcode); + * @endcode + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getViewBuilder() + * @see \Drupal\Core\Entity\EntityViewBuilderInterface::view() */ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) { $render_controller = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId()); @@ -333,10 +378,15 @@ * 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. + * Use the entity view builder's viewMultiple method for creating a render + * array for the provided entities: + * @code * $view_builder = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId()); * return $view_builder->viewMultiple($entities, $view_mode, $langcode); + * @endcode + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getViewBuilder() + * @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewMultiple() */ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) { $render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->getEntityTypeId()); @@ -386,9 +436,13 @@ * 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: + * If the display is available in configuration use: + * @code * \Drupal::entityManager()->getStorage('entity_view_display')->load($entity_type . '.' . $bundle . '.' . $view_mode); - * else use: + * @endcode + * When the display is not available in configuration, you can create a new + * EntityViewDisplay object using: + * @code * $values = ('entity_view_display', array( * 'targetEntityType' => $entity_type, * 'bundle' => $bundle, @@ -396,6 +450,10 @@ * 'status' => TRUE, * )); * \Drupal::entityManager()->getStorage('entity_view_display')->create($values); + * @endcode + * + * @see \Drupal\Core\Entity\EntityStorageInterface::create() + * @see \Drupal\Core\Entity\EntityStorageInterface::load() */ function entity_get_display($entity_type, $bundle, $view_mode) { // Try loading the display from configuration. @@ -453,10 +511,14 @@ * @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: + * @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. + * If the entity form display is available in configuration use: + * @code * \Drupal::entityManager()->getStorage('entity_form_display')->load($entity_type . '.' . $bundle . '.' . $form_mode); - * else use: + * @endcode + * When the entity form display is not available in configuration, you can create a new + * EntityFormDisplay object using: + * @code * $values = ('entity_form_display', array( * 'targetEntityType' => $entity_type, * 'bundle' => $bundle, @@ -464,6 +526,10 @@ * 'status' => TRUE, * )); * \Drupal::entityManager()->getStorage('entity_form_display')->create($values); + * @endcode + * + * @see \Drupal\Core\Entity\EntityStorageInterface::create() + * @see \Drupal\Core\Entity\EntityStorageInterface::load() */ function entity_get_form_display($entity_type, $bundle, $form_mode) { // Try loading the entity from configuration.