* Removed service locator resolvning UmbracoMapper (Current.Mapper) in the UmbracoApiControllerBase constructor.
* Added Obsolete marker to old UmbracoApiController constructor injecting Current.Mapper for backward compability, use new full construcor injection instead.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using Umbraco.Core;
|
||||
using System;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
@@ -17,8 +19,14 @@ namespace Umbraco.Web.WebApi
|
||||
{
|
||||
}
|
||||
|
||||
[Obsolete("This constructor uses the service locator to fetch the UmbracoMapper from Current.Mapper, which is not good for testability. Inject the UmbracoMapper using full constructor injection instead.")]
|
||||
protected UmbracoApiController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, Current.Mapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected UmbracoApiController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, UmbracoMapper umbracoMapper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, umbracoMapper)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,14 +40,15 @@ namespace Umbraco.Web.WebApi
|
||||
Current.Factory.GetInstance<AppCaches>(),
|
||||
Current.Factory.GetInstance<IProfilingLogger>(),
|
||||
Current.Factory.GetInstance<IRuntimeState>(),
|
||||
Current.Factory.GetInstance<UmbracoHelper>()
|
||||
Current.Factory.GetInstance<UmbracoHelper>(),
|
||||
Current.Factory.GetInstance<UmbracoMapper>()
|
||||
)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoApiControllerBase"/> class with all its dependencies.
|
||||
/// </summary>
|
||||
protected UmbracoApiControllerBase(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
|
||||
protected UmbracoApiControllerBase(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, UmbracoMapper umbracoMapper)
|
||||
{
|
||||
UmbracoContextAccessor = umbracoContextAccessor;
|
||||
GlobalSettings = globalSettings;
|
||||
@@ -57,9 +58,7 @@ namespace Umbraco.Web.WebApi
|
||||
Logger = logger;
|
||||
RuntimeState = runtimeState;
|
||||
Umbraco = umbracoHelper;
|
||||
|
||||
// fixme - can we break all ctors?
|
||||
Mapper = Current.Mapper;
|
||||
Mapper = umbracoMapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user