fixed todo in AspNetCore Backoffice

This commit is contained in:
Zeegaan
2021-08-17 09:55:57 +02:00
parent a4b6fc8db6
commit 45bbaafde9
2 changed files with 27 additions and 5 deletions

View File

@@ -136,7 +136,7 @@ namespace Umbraco.Cms.Tests.Integration.Implementations
{
var globalSettings = new GlobalSettings();
IOptionsMonitor<GlobalSettings> mockedOptionsMonitorOfGlobalSettings = Mock.Of<IOptionsMonitor<GlobalSettings>>(x => x.CurrentValue == globalSettings);
_backOfficeInfo = new AspNetCoreBackOfficeInfo(mockedOptionsMonitorOfGlobalSettings);
_backOfficeInfo = new AspNetCoreBackOfficeInfo(mockedOptionsMonitorOfGlobalSettings, null);
}
return _backOfficeInfo;

View File

@@ -1,17 +1,39 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Routing;
using static Umbraco.Cms.Core.Constants;
namespace Umbraco.Cms.Web.Common.AspNetCore
{
public class AspNetCoreBackOfficeInfo : IBackOfficeInfo
{
public AspNetCoreBackOfficeInfo(IOptionsMonitor<GlobalSettings> globalSettings)
private readonly IOptionsMonitor<GlobalSettings> _globalSettings;
private readonly IHostingEnvironment _hostingEnvironment;
private string _getAbsoluteUrl;
public AspNetCoreBackOfficeInfo(IOptionsMonitor<GlobalSettings> globalSettings, IHostingEnvironment hostingEnviroment)
{
GetAbsoluteUrl = globalSettings.CurrentValue.UmbracoPath;
_globalSettings = globalSettings;
_hostingEnvironment = hostingEnviroment;
//GetAbsoluteUrl= WebPath.Combine(hostingEnviroment.ApplicationMainUrl.ToString(), globalSettings.CurrentValue.UmbracoPath.TrimStart(CharArrays.TildeForwardSlash));
}
public string GetAbsoluteUrl { get; } // TODO make absolute
public string GetAbsoluteUrl
{
get
{
if (_getAbsoluteUrl is null)
{
if(_hostingEnvironment.ApplicationMainUrl is null)
{
return "";
}
_getAbsoluteUrl = WebPath.Combine(_hostingEnvironment.ApplicationMainUrl.ToString(), _globalSettings.CurrentValue.UmbracoPath.TrimStart(CharArrays.TildeForwardSlash));
}
return _getAbsoluteUrl;
}
}
}
}