Back to Access class

Method getAssetName

protected static string
getAssetName
(mixed $assetKey)
Method to get the asset name from the asset key.
Parameters
  • int|string $assetKey The asset key (asset id or asset name).
Returns
  • string The asset name (ex: com_content.article.8).
Since
  • 3.7.0
Class: Access
Project: Joomla

Method getAssetName - Source code

/**
 * Method to get the asset name from the asset key.
 *
 * @param   integer|string  $assetKey  The asset key (asset id or asset name).
 *
 * @return  string  The asset name (ex: com_content.article.8).
 *
 * @since   3.7.0
 */
protected static function getAssetName($assetKey)
{
    static $loaded = array();
    // If the asset is already a string return it.
    if (!is_numeric($assetKey)) {
        return $assetKey;
    }
    if (!isset($loaded[$assetKey])) {
        // It's the root asset.
        if (self::$rootAssetId !== null && $assetKey === self::$rootAssetId) {
            $loaded[$assetKey] = self::$preloadedAssets[self::$rootAssetId];
        } elseif (isset(self::$preloadedAssets[$assetKey])) {
            $loaded[$assetKey] = self::$preloadedAssets[$assetKey];
        } else {
            $table = new Asset(Factory::getDbo());
            $table->load($assetKey);
            $loaded[$assetKey] = $table->name;
        }
    }
    return $loaded[$assetKey];
}