protected static Url::fromEntityUri(array $uri_parts, array $options, $uri)
Create a new Url object for entity URIs.
Parameters
array $uri_parts: Parts from an URI of the form entity:{entity_type}/{entity_id} as from parse_url().
array $options: An array of options, see \Drupal\Core\Url::fromUri() for details.
string $uri: The original entered URI.
Return value
\Drupal\Core\Url A new Url object for an entity's canonical route.
Throws
\InvalidArgumentException Thrown if the entity URI is invalid.
File
- core/lib/Drupal/Core/Url.php, line 340
Class
- Url
- Defines an object that holds information about a URL.
Namespace
Drupal\Core
Code
protected static function fromEntityUri(array $uri_parts, array $options, $uri) { list($entity_type_id, $entity_id) = explode('/', $uri_parts['path'], 2); if ($uri_parts['scheme'] != 'entity' || $entity_id === '') { throw new \InvalidArgumentException("The entity URI '$uri' is invalid. You must specify the entity id in the URL. e.g., entity:node/1 for loading the canonical path to node entity with id 1."); } return new static("entity.$entity_type_id.canonical", [$entity_type_id => $entity_id], $options); }
Please login to continue.