public static function getByName($name, $siteId = null)
{
$cacheKey = $name . "~~~" . $siteId;
// check if pimcore already knows the id for this $name, if yes just return it
if (array_key_exists($cacheKey, self::$nameIdMappingCache)) {
return self::getById(self::$nameIdMappingCache[$cacheKey]);
}
// create a tmp object to obtain the id
$route = new self();
try {
$route->getDao()->getByName($name, $siteId);
} catch (\Exception $e) {
Logger::warn($e);
return null;
}
// to have a singleton in a way. like all instances of Element\ElementInterface do also, like Object\AbstractObject
if ($route->getId() > 0) {
// add it to the mini-per request cache
self::$nameIdMappingCache[$cacheKey] = $route->getId();
return self::getById($route->getId());
}
}