Fixed duplications

This commit is contained in:
Zeegaan
2021-08-17 11:41:28 +02:00
parent 6c545a29c7
commit 285c9c92b5
3 changed files with 7 additions and 21 deletions

View File

@@ -31,10 +31,7 @@ namespace Umbraco.Cms.Web.Common.Controllers
{
get
{
if (!UmbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
{
throw new InvalidOperationException("Wasn't able to get an UmbracoContext");
}
var umbracoContext = UmbracoContextAccessor.GetRequiredUmbracoContext();
return umbracoContext;
}
}

View File

@@ -11,6 +11,7 @@ using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Web.Common.ActionsResults;
using Umbraco.Cms.Web.Common.Filters;
using Umbraco.Extensions;
namespace Umbraco.Cms.Web.Common.Controllers
{
@@ -42,10 +43,7 @@ namespace Umbraco.Cms.Web.Common.Controllers
{
get
{
if (!_umbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
{
throw new InvalidOperationException("Wasn't able to get an UmbracoContext");
}
var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();
return umbracoContext;
}
}

View File

@@ -49,11 +49,8 @@ namespace Umbraco.Extensions
/// </remarks>
public static string GetCultureFromDomains(this IPublishedContent content, IUmbracoContextAccessor umbracoContextAccessor, ISiteDomainMapper siteDomainHelper, Uri current = null)
{
if (!umbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
{
throw new InvalidOperationException("Wasn't able to get an UmbracoContext");
}
return DomainUtilities.GetCultureFromDomains(content.Id, content.Path, current, umbracoContext, siteDomainHelper);
var umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
return DomainUtilities.GetCultureFromDomains(content.Id, content.Path, current, umbracoContext, siteDomainHelper);
}
#endregion
@@ -75,10 +72,7 @@ namespace Umbraco.Extensions
.Field(UmbracoExamineFieldNames.IndexPathFieldName, (content.Path + ",").MultipleCharacterWildcard())
.And()
.ManagedQuery(term);
if (!umbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
{
throw new InvalidOperationException("Wasn't able to get an UmbracoContext");
}
var umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
return query.Execute().ToPublishedSearchResults(umbracoContext.Content);
}
@@ -97,10 +91,7 @@ namespace Umbraco.Extensions
.Field("parentID", content.Id)
.And()
.ManagedQuery(term);
if (!umbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
{
throw new InvalidOperationException("Wasn't able to get an UmbracoContext");
}
var umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
return query.Execute().ToPublishedSearchResults(umbracoContext.Content);
}