Fixed 11 more classes with new TryGetUmbracoContext

This commit is contained in:
Zeegaan
2021-08-11 12:17:35 +02:00
parent 919b091e67
commit c3bac00f6e
11 changed files with 93 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Concurrent;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Cache;
@@ -27,7 +27,17 @@ namespace Umbraco.Cms.Web.Common.Controllers
/// <summary>
/// Gets the Umbraco context.
/// </summary>
public virtual IUmbracoContext UmbracoContext => UmbracoContextAccessor.UmbracoContext;
public virtual IUmbracoContext UmbracoContext
{
get
{
if (!UmbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
{
throw new InvalidOperationException("Wasn't able to get an UmbracoContext");
}
return umbracoContext;
}
}
/// <summary>
/// Gets the database context accessor.