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:
16
src/Umbraco.Core/Extensions/LanguageServiceExtensions.cs
Normal file
16
src/Umbraco.Core/Extensions/LanguageServiceExtensions.cs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user