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,46 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Web.Common.Attributes;
|
||||
using Umbraco.Extensions;
|
||||
using Constants = Umbraco.Cms.Core.Constants;
|
||||
using Stylesheet = Umbraco.Cms.Core.Models.ContentEditing.Stylesheet;
|
||||
|
||||
namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
namespace Umbraco.Cms.Web.BackOffice.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// The API controller used for retrieving available stylesheets
|
||||
/// </summary>
|
||||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
||||
public class StylesheetController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
/// <summary>
|
||||
/// The API controller used for retrieving available stylesheets
|
||||
/// </summary>
|
||||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
||||
public class StylesheetController : UmbracoAuthorizedJsonController
|
||||
private readonly IFileService _fileService;
|
||||
|
||||
public StylesheetController(IFileService fileService) => _fileService = fileService;
|
||||
|
||||
public IEnumerable<Stylesheet> GetAll() =>
|
||||
_fileService.GetStylesheets()
|
||||
.Select(x =>
|
||||
new Stylesheet { Name = x.Alias, Path = x.VirtualPath });
|
||||
|
||||
public IEnumerable<StylesheetRule> GetRulesByName(string name)
|
||||
{
|
||||
private readonly IFileService _fileService;
|
||||
|
||||
public StylesheetController(IFileService fileService)
|
||||
IStylesheet? css = _fileService.GetStylesheet(name.EnsureEndsWith(".css"));
|
||||
if (css is null || css.Properties is null)
|
||||
{
|
||||
_fileService = fileService;
|
||||
return Enumerable.Empty<StylesheetRule>();
|
||||
}
|
||||
|
||||
public IEnumerable<Stylesheet> GetAll()
|
||||
{
|
||||
return _fileService.GetStylesheets()
|
||||
.Select(x =>
|
||||
new Stylesheet() {
|
||||
Name = x.Alias,
|
||||
Path = x.VirtualPath
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<StylesheetRule> GetRulesByName(string name)
|
||||
{
|
||||
var css = _fileService.GetStylesheet(name.EnsureEndsWith(".css"));
|
||||
if (css is null || css.Properties is null)
|
||||
{
|
||||
return Enumerable.Empty<StylesheetRule>();
|
||||
}
|
||||
|
||||
return css.Properties.Select(x => new StylesheetRule() { Name = x.Name, Selector = x.Alias });
|
||||
}
|
||||
return css.Properties.Select(x => new StylesheetRule { Name = x.Name, Selector = x.Alias });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user