diff --git a/core/includes/common.inc b/core/includes/common.inc index 17e1363a5c1f..084220120020 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2090,9 +2090,9 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) { * Defaults to empty string when clean URLs are in effect, and to * 'index.php/' when they are not. * - 'entity_type': The entity type of the object that called url(). Only - * set if url() is invoked by entity_uri(). + * set if url() is invoked by Drupal\entity\Entity::uri(). * - 'entity': The entity object (such as a node) for which the URL is being - * generated. Only set if url() is invoked by entity_uri(). + * generated. Only set if url() is invoked by Drupal\entity\Entity::uri(). * * @return * A string containing a URL to the given path. diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index c0d142691586..5db5442746d5 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1756,7 +1756,7 @@ function template_preprocess_comment(&$variables) { $variables['user_picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : ''; $variables['signature'] = $comment->signature; - $uri = entity_uri('comment', $comment); + $uri = $comment->uri(); $uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark')); $variables['title'] = l($comment->subject, $uri['path'], $uri['options']); diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index 3819e4bd5bc0..2c54daa8748c 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -6,7 +6,6 @@ */ use \InvalidArgumentException; - use Drupal\entity\EntityFieldQuery; use Drupal\entity\EntityMalformedException; use Drupal\entity\EntityStorageException; @@ -371,48 +370,6 @@ function entity_prepare_view($entity_type, $entities) { } } -/** - * Returns the uri elements of an entity. - * - * @param $entity_type - * The entity type; e.g. 'node' or 'user'. - * @param $entity - * The entity for which to generate a path. - * - * @return - * An array containing the 'path' and 'options' keys used to build the uri of - * the entity, and matching the signature of url(). NULL if the entity has no - * uri of its own. - * - * @todo - * Remove once all entity types are implementing the EntityInterface. - */ -function entity_uri($entity_type, $entity) { - $info = entity_get_info($entity_type); - - // A bundle-specific callback takes precedence over the generic one for the - // entity type. - if (isset($info['bundles'][$entity->bundle()]['uri callback'])) { - $uri_callback = $info['bundles'][$entity->bundle()]['uri callback']; - } - elseif (isset($info['uri callback'])) { - $uri_callback = $info['uri callback']; - } - else { - return NULL; - } - - // Invoke the callback to get the URI. If there is no callback, return NULL. - if (isset($uri_callback)) { - $uri = $uri_callback($entity); - // Pass the entity data to url() so that alter functions do not need to - // lookup this entity again. - $uri['options']['entity_type'] = $entity_type; - $uri['options']['entity'] = $entity; - return $uri; - } -} - /** * Returns the label of an entity. * diff --git a/core/modules/entity/lib/Drupal/entity/Entity.php b/core/modules/entity/lib/Drupal/entity/Entity.php index 151146a6842f..b986e3be5b2f 100644 --- a/core/modules/entity/lib/Drupal/entity/Entity.php +++ b/core/modules/entity/lib/Drupal/entity/Entity.php @@ -117,8 +117,6 @@ class Entity implements EntityInterface { /** * Implements EntityInterface::uri(). - * - * @see entity_uri() */ public function uri() { $bundle = $this->bundle(); diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc index 80b8fb83c5b0..09b07eb4355d 100644 --- a/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -546,7 +546,7 @@ function image_field_formatter_view($entity_type, $entity, $field, $instance, $l // Check if the formatter involves a link. if ($display['settings']['image_link'] == 'content') { - $uri = entity_uri($entity_type, $entity); + $uri = $entity->uri(); } elseif ($display['settings']['image_link'] == 'file') { $link_file = TRUE; diff --git a/core/modules/node/node.module b/core/modules/node/node.module index e04d89d1d263..1b0d670f5ea1 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1330,7 +1330,7 @@ function template_preprocess_node(&$variables) { 'link_attributes' => array('rel' => 'author'), )); - $uri = entity_uri('node', $node); + $uri = $node->uri(); $variables['node_url'] = url($uri['path'], $uri['options']); $variables['title'] = check_plain($node->title); $variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node); @@ -1568,7 +1568,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) { $extra = module_invoke_all('node_search_result', $node, $item->langcode); $language = language_load($item->langcode); - $uri = entity_uri('node', $node); + $uri = $node->uri(); $results[] = array( 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), 'type' => check_plain(node_type_get_name($node)), @@ -2561,7 +2561,7 @@ function node_page_view(Node $node) { // of the active trail, and the link name becomes the page title. // Thus, we must explicitly set the page title to be the node title. drupal_set_title($node->label()); - $uri = entity_uri('node', $node); + $uri = $node->uri(); // Set the node path as the canonical URL to prevent duplicate content. drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE); // Set the non-aliased path as a default shortlink. diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index fe2bd0012f2b..a61760c1b3ff 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -598,7 +598,7 @@ function rdf_preprocess_field(&$variables) { */ function rdf_preprocess_user_profile(&$variables) { $account = $variables['elements']['#account']; - $uri = entity_uri('user', $account); + $uri = $account->uri(); // Adds RDFa markup to the user profile page. Fields displayed in this page // will automatically describe the user. @@ -695,7 +695,7 @@ function rdf_preprocess_comment(&$variables) { // the URI of the resource described within the HTML element, while the // typeof attribute indicates its RDF type (e.g., sioc:Post, foaf:Document, // and so on.) - $uri = entity_uri('comment', $comment); + $uri = $comment->uri(); $variables['attributes']['about'] = url($uri['path'], $uri['options']); $variables['attributes']['typeof'] = $comment->rdf_mapping['rdftype']; } diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php index 40ac0d562316..4c244753a3a6 100644 --- a/core/modules/search/search.api.php +++ b/core/modules/search/search.api.php @@ -236,7 +236,7 @@ function hook_search_execute($keys = NULL, $conditions = NULL) { $extra = module_invoke_all('node_search_result', $node, $item->langcode); $language = language_load($item->langcode); - $uri = entity_uri('node', $node); + $uri = $node->uri(); $results[] = array( 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), 'type' => check_plain(node_type_get_name($node)), diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 3bd18c8fb085..a37da8aed9a5 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -625,7 +625,7 @@ function template_preprocess_taxonomy_term(&$variables) { $variables['term'] = $variables['elements']['#term']; $term = $variables['term']; - $uri = entity_uri('taxonomy_term', $term); + $uri = $term->uri(); $variables['term_url'] = url($uri['path'], $uri['options']); $variables['term_name'] = check_plain($term->name); $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term); @@ -1230,7 +1230,7 @@ function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, } else { $term = $item['taxonomy_term']; - $uri = entity_uri('taxonomy_term', $term); + $uri = $term->uri(); $element[$delta] = array( '#type' => 'link', '#title' => $term->label(), diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc index 24d7bc83d5b5..c7847b3a6054 100644 --- a/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -110,7 +110,7 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options = break; case 'url': - $uri = entity_uri('taxonomy_term', $term); + $uri = $term->uri(); $replacements[$original] = url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE))); break; diff --git a/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php index 9c88aeca44cd..84134b77dfd7 100644 --- a/core/modules/user/lib/Drupal/user/RegisterFormController.php +++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php @@ -116,7 +116,7 @@ class RegisterFormController extends AccountFormController { $account->password = $pass; // New administrative account without notification. - $uri = entity_uri('user', $account); + $uri = $account->uri(); if ($admin && !$notify) { drupal_set_message(t('Created a new user account for %name. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name))); } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php index 6d74849fe78e..a631620216ce 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php @@ -52,7 +52,7 @@ class UserEntityCallbacksTest extends WebTestBase { * Test URI callback. */ function testUriCallback() { - $uri = entity_uri('user', $this->account); + $uri = $this->account->uri(); $this->assertEqual('user/' . $this->account->uid, $uri['path'], t('Correct user URI.')); } }