You are here

public function EntityHelper::getEntityFromUrlObject in Simple XML sitemap 8.2

Same name and namespace in other branches
  1. 8.3 src/EntityHelper.php \Drupal\simple_sitemap\EntityHelper::getEntityFromUrlObject()

Parameters

$url_object:

Return value

object|null

File

src/EntityHelper.php, line 106

Class

EntityHelper
Class EntityHelper @package Drupal\simple_sitemap

Namespace

Drupal\simple_sitemap

Code

public function getEntityFromUrlObject(Url $url_object) {
  return $url_object
    ->isRouted() && !empty($route_parameters = $url_object
    ->getRouteParameters()) && $this->entityTypeManager
    ->getDefinition($entity_type_id = key($route_parameters), FALSE) ? $this->entityTypeManager
    ->getStorage($entity_type_id)
    ->load($route_parameters[$entity_type_id]) : NULL;
}