/**
* Method to clean the asset key to make sure we always have something.
*
* @param integer|string $assetKey The asset key (asset id or asset name). null fallback to root asset.
*
* @return integer|string Asset id or asset name.
*
* @since 3.7.0
*/
protected static function cleanAssetKey($assetKey = null)
{
// If it's a valid asset key, clean it and return it.
if ($assetKey) {
return strtolower(preg_replace('#[\\s\\-]+#', '.', trim($assetKey)));
}
// Return root asset id if already preloaded.
if (self::$rootAssetId !== null) {
return self::$rootAssetId;
}
// No preload. Return root asset id from Assets.
$assets = new Asset(Factory::getDbo());
return $assets->getRootId();
}