Introduce IUmbracoContextFactory
This commit is contained in:
@@ -47,6 +47,7 @@ namespace Umbraco.Web
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPublishedRouter _publishedRouter;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly IUmbracoContextFactory _umbracoContextFactory;
|
||||
|
||||
public UmbracoInjectedModule(
|
||||
IGlobalSettings globalSettings,
|
||||
@@ -57,7 +58,8 @@ namespace Umbraco.Web
|
||||
IRuntimeState runtime,
|
||||
ILogger logger,
|
||||
IPublishedRouter publishedRouter,
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IUmbracoContextFactory umbracoContextFactory)
|
||||
{
|
||||
_combinedRouteCollection = new Lazy<RouteCollection>(CreateRouteCollection);
|
||||
|
||||
@@ -70,6 +72,7 @@ namespace Umbraco.Web
|
||||
_logger = logger;
|
||||
_publishedRouter = publishedRouter;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
_umbracoContextFactory = umbracoContextFactory;
|
||||
}
|
||||
|
||||
#region HttpModule event handlers
|
||||
@@ -92,18 +95,10 @@ namespace Umbraco.Web
|
||||
|
||||
// ok, process
|
||||
|
||||
// create the UmbracoContext singleton, one per request, and assign
|
||||
// replace existing if any (eg during app startup, a temp one is created)
|
||||
UmbracoContext.EnsureContext(
|
||||
_umbracoContextAccessor,
|
||||
httpContext,
|
||||
_publishedSnapshotService,
|
||||
new WebSecurity(httpContext, _userService, _globalSettings),
|
||||
Current.Configs.Settings(),
|
||||
_urlProviders,
|
||||
_globalSettings,
|
||||
_variationContextAccessor,
|
||||
true);
|
||||
// ensure there's an UmbracoContext registered for the current request
|
||||
// registers the context reference so its disposed at end of request
|
||||
var umbracoContextReference = _umbracoContextFactory.EnsureUmbracoContext(httpContext);
|
||||
httpContext.DisposeOnPipelineCompleted(umbracoContextReference);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user