V10: fix build warnings in Web.BackOffice (#12479)
* Run code cleanup * Start manual run * Finish dotnet format + manual cleanup * Fix up after merge * Fix substrings changed to [..] Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
@@ -1,51 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Hosting;
|
||||
using Umbraco.Cms.Core.IO;
|
||||
using Umbraco.Cms.Web.Common.Attributes;
|
||||
using Constants = Umbraco.Cms.Core.Constants;
|
||||
|
||||
namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
namespace Umbraco.Cms.Web.BackOffice.Controllers;
|
||||
|
||||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
||||
public class BackOfficeAssetsController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
||||
public class BackOfficeAssetsController : UmbracoAuthorizedJsonController
|
||||
private readonly IFileSystem _jsLibFileSystem;
|
||||
|
||||
public BackOfficeAssetsController(IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory, IOptionsSnapshot<GlobalSettings> globalSettings)
|
||||
{
|
||||
private readonly IFileSystem _jsLibFileSystem;
|
||||
var path = globalSettings.Value.UmbracoPath + Path.DirectorySeparatorChar + "lib";
|
||||
_jsLibFileSystem = new PhysicalFileSystem(
|
||||
ioHelper,
|
||||
hostingEnvironment,
|
||||
loggerFactory.CreateLogger<PhysicalFileSystem>(),
|
||||
hostingEnvironment.MapPathWebRoot(path),
|
||||
hostingEnvironment.ToAbsolute(path));
|
||||
}
|
||||
|
||||
public BackOfficeAssetsController(IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory, IOptionsSnapshot<GlobalSettings> globalSettings)
|
||||
[HttpGet]
|
||||
public object GetSupportedLocales()
|
||||
{
|
||||
const string momentLocaleFolder = "moment";
|
||||
const string flatpickrLocaleFolder = "flatpickr/l10n";
|
||||
|
||||
return new { moment = GetLocales(momentLocaleFolder), flatpickr = GetLocales(flatpickrLocaleFolder) };
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetLocales(string path)
|
||||
{
|
||||
var cultures = _jsLibFileSystem.GetFiles(path, "*.js").ToList();
|
||||
for (var i = 0; i < cultures.Count; i++)
|
||||
{
|
||||
var path = globalSettings.Value.UmbracoPath + Path.DirectorySeparatorChar + "lib";
|
||||
_jsLibFileSystem = new PhysicalFileSystem(ioHelper, hostingEnvironment, loggerFactory.CreateLogger<PhysicalFileSystem>(), hostingEnvironment.MapPathWebRoot(path), hostingEnvironment.ToAbsolute(path));
|
||||
cultures[i] = cultures[i].Substring(cultures[i].IndexOf(path, StringComparison.Ordinal) + path.Length + 1);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public object GetSupportedLocales()
|
||||
{
|
||||
const string momentLocaleFolder = "moment";
|
||||
const string flatpickrLocaleFolder = "flatpickr/l10n";
|
||||
|
||||
return new
|
||||
{
|
||||
moment = GetLocales(momentLocaleFolder),
|
||||
flatpickr = GetLocales(flatpickrLocaleFolder)
|
||||
};
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetLocales(string path)
|
||||
{
|
||||
var cultures = _jsLibFileSystem.GetFiles(path, "*.js").ToList();
|
||||
for (var i = 0; i < cultures.Count; i++)
|
||||
{
|
||||
cultures[i] = cultures[i]
|
||||
.Substring(cultures[i].IndexOf(path, StringComparison.Ordinal) + path.Length + 1);
|
||||
}
|
||||
return cultures;
|
||||
}
|
||||
return cultures;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user