Fixed 11 more classes with new TryGetUmbracoContext
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Examine;
|
||||
@@ -50,7 +50,17 @@ namespace Umbraco.Extensions
|
||||
private static IPublishedValueFallback PublishedValueFallback { get; } =
|
||||
StaticServiceProvider.Instance.GetRequiredService<IPublishedValueFallback>();
|
||||
|
||||
private static IPublishedSnapshot PublishedSnapshot => UmbracoContextAccessor.UmbracoContext?.PublishedSnapshot;
|
||||
private static IPublishedSnapshot PublishedSnapshot
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!UmbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return umbracoContext.PublishedSnapshot;
|
||||
}
|
||||
}
|
||||
|
||||
private static IMediaTypeService MediaTypeService { get; } =
|
||||
StaticServiceProvider.Instance.GetRequiredService<IMediaTypeService>();
|
||||
|
||||
@@ -48,7 +48,13 @@ namespace Umbraco.Extensions
|
||||
/// a culture to that document.</para>
|
||||
/// </remarks>
|
||||
public static string GetCultureFromDomains(this IPublishedContent content, IUmbracoContextAccessor umbracoContextAccessor, ISiteDomainMapper siteDomainHelper, Uri current = null)
|
||||
=> DomainUtilities.GetCultureFromDomains(content.Id, content.Path, current, umbracoContextAccessor.UmbracoContext, siteDomainHelper);
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user