/**
* Method to get the asset type from the asset name.
*
* For top level components this returns "components":
* 'com_content' returns 'components'
*
* For other types:
* 'com_content.article.1' returns 'com_content.article'
* 'com_content.category.1' returns 'com_content.category'
*
* @param integer|string $assetKey The asset key (asset id or asset name).
*
* @return string The asset type (ex: com_content.article).
*
* @since 1.6
*/
public static function getAssetType($assetKey)
{
// If the asset is already a string return it.
$assetName = self::getAssetName($assetKey);
$lastDot = strrpos($assetName, '.');
if ($assetName !== 'root.1' && $lastDot !== false) {
return substr($assetName, 0, $lastDot);
}
return 'components';
}