I have a URI 'entity:node/27' and I want to load this entity, but I cannot find the correct helper function or class to use.
I do not want to explode the string or regex the string, I am fairly sure there is a function for this.
I have a URI 'entity:node/27' and I want to load this entity, but I cannot find the correct helper function or class to use.
I do not want to explode the string or regex the string, I am fairly sure there is a function for this.
$params = Url::fromUri("internal:" . $source_uri)->getRouteParameters();
$entity_type = key($params);
$entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($params[$entity_type]);