Refactoring: Add extension method for retrieval of language ISO codes if that's all we need (#20324)

* Retrieve only ISO codes from the database rather than full language objects if that's all we need.

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Removed repository updates and migrated the new service method to an extension method.

* Fixed issue after merge.

* Removed left-over using

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
This commit is contained in:
Andy Butland
2025-10-01 20:21:41 +02:00
committed by GitHub
parent 3f0428c8ef
commit 78f4caa2be
15 changed files with 64 additions and 35 deletions

View File

@@ -0,0 +1,16 @@
using Umbraco.Cms.Core.Services;
namespace Umbraco.Cms.Core.Extensions;
/// <summary>
/// Provides extension methods for <see cref="ILanguageService"/>.
/// </summary>
public static class LanguageServiceExtensions
{
/// <summary>
/// Retrieves all ISO codes of all languages.
/// </summary>
/// <param name="service">The <see cref="ILanguageService"/>.</param>
/// <returns>A collection of language ISO codes.</returns>
public static async Task<IEnumerable<string>> GetAllIsoCodesAsync(this ILanguageService service) => (await service.GetAllAsync()).Select(x => x.IsoCode);
}