Issue #2474151 by JeroenT, dcmul, naveenvalecha, sorabh.v6, trwad, Nitesh Sethia, sushilkr, disasm, dylanf, Mile23, xjm, dawehner, tim.plunkett, andypost: Mark procedural wrappers in entity.inc as deprecated

8.0.x
Alex Pott 2015-07-30 15:21:44 +01:00
parent 6ba0114eed
commit b7fe1509dd
1 changed files with 154 additions and 15 deletions

View File

@ -61,8 +61,18 @@ function entity_get_bundles($entity_type = NULL) {
* @return \Drupal\Core\Entity\EntityInterface|null
* The entity object, or NULL if there is no entity with the given ID.
*
* @see \Drupal\Core\Entity\EntityManagerInterface
* @see \Drupal\Core\Entity\EntityStorageInterface
* @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
* 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
*/
@ -86,8 +96,15 @@ function entity_load($entity_type, $id, $reset = FALSE) {
* The entity object, or NULL if there is no entity with the given revision
* id.
*
* @see \Drupal\Core\Entity\EntityManagerInterface
* @see \Drupal\Core\Entity\EntityStorageInterface
* @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::getStorage()
* @see \Drupal\Core\Entity\EntityStorageInterface::loadRevision()
* @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage
*/
function entity_revision_load($entity_type, $revision_id) {
@ -103,6 +120,16 @@ 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
* 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()
@ -139,8 +166,18 @@ function entity_revision_delete($entity_type, $revision_id) {
* @return array
* An array of entity objects indexed by their IDs.
*
* @see \Drupal\Core\Entity\EntityManagerInterface
* @see \Drupal\Core\Entity\EntityStorageInterface
* @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
* 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
*/
@ -164,6 +201,16 @@ 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
* the entity storage's loadByProperties() method to load an entity by their
* property values:
* @code
* \Drupal::entityManager()->getStorage($entity_type)->loadByProperties($values);
* @endcode
*
* @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()
@ -184,8 +231,17 @@ function entity_load_multiple_by_properties($entity_type, array $values) {
* @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
* the entity storage's loadUnchanged() method to load an unchanged entity:
* @code
* \Drupal::entityManager()->getStorage($entity_type)->loadUnchanged($id).
* @endcode
*
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
* @see \Drupal\Core\Entity\EntityStorageInterface::loadUnchanged()
*/
function entity_load_unchanged($entity_type, $id) {
return \Drupal::entityManager()
@ -200,6 +256,18 @@ 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
* 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);
@ -219,10 +287,17 @@ 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 <EntityType>::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()
@ -233,9 +308,6 @@ 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.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity for which to generate the label.
* @param $langcode
@ -243,9 +315,15 @@ function entity_create($entity_type, array $values = array()) {
* 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. Use
* the entity's label() method to get the label of the entity:
* @code
* $entity->label($langcode);
* @endcode
*
* @see \Drupal\Core\Entity\EntityInterface::label()
*/
function entity_page_label(EntityInterface $entity, $langcode = NULL) {
@ -268,6 +346,16 @@ 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 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());
@ -294,6 +382,17 @@ 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 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());
@ -341,6 +440,26 @@ 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 the display is available in configuration use:
* @code
* \Drupal::entityManager()->getStorage('entity_view_display')->load($entity_type . '.' . $bundle . '.' . $view_mode);
* @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,
* 'mode' => $view_mode,
* '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.
@ -397,6 +516,26 @@ 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.
* If the entity form display is available in configuration use:
* @code
* \Drupal::entityManager()->getStorage('entity_form_display')->load($entity_type . '.' . $bundle . '.' . $form_mode);
* @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,
* 'mode' => $form_mode,
* '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.