Fixed 11 more classes with new TryGetUmbracoContext
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user