Merge branch 'netcore/feature/move-files-after-umbraco-context-abstractions' into netcore/feature/move-mappings-after-httpcontext

# Conflicts:
#	src/Umbraco.Web/Install/InstallHelper.cs
#	src/Umbraco.Web/Models/Mapping/CommonMapper.cs
This commit is contained in:
Bjarke Berg
2020-02-19 11:40:25 +01:00
47 changed files with 207 additions and 199 deletions

View File

@@ -24,17 +24,17 @@ namespace Umbraco.Web.Models.Mapping
private readonly ContentAppFactoryCollection _contentAppDefinitions;
private readonly ILocalizedTextService _localizedTextService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ICurrentUserAccessor _currentUserAccessor;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
public CommonMapper(IUserService userService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider,
ContentAppFactoryCollection contentAppDefinitions, ILocalizedTextService localizedTextService, IHttpContextAccessor httpContextAccessor, ICurrentUserAccessor currentUserAccessor)
public CommonMapper(IUserService userService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IUmbracoContextAccessor umbracoContextAccessor,
ContentAppFactoryCollection contentAppDefinitions, ILocalizedTextService localizedTextService, IHttpContextAccessor httpContextAccessor)
{
_userService = userService;
_contentTypeBaseServiceProvider = contentTypeBaseServiceProvider;
_contentAppDefinitions = contentAppDefinitions;
_localizedTextService = localizedTextService;
_httpContextAccessor = httpContextAccessor;
_currentUserAccessor = currentUserAccessor;
_umbracoContextAccessor = umbracoContextAccessor;
}
public UserProfile GetOwner(IContentBase source, MapperContext context)
@@ -52,7 +52,7 @@ namespace Umbraco.Web.Models.Mapping
public ContentTypeBasic GetContentType(IContentBase source, MapperContext context)
{
var user = _currentUserAccessor.TryGetCurrentUser();
var user = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser;
if (user?.AllowedSections.Any(x => x.Equals(Constants.Applications.Settings)) ?? false)
{
var contentType = _contentTypeBaseServiceProvider.GetContentTypeOf(source);

View File

@@ -18,21 +18,19 @@ namespace Umbraco.Web.Models.Mapping
public class MediaMapDefinition : IMapDefinition
{
private readonly CommonMapper _commonMapper;
private readonly ILogger _logger;
private readonly IMediaService _mediaService;
private readonly IMediaTypeService _mediaTypeService;
private readonly PropertyEditorCollection _propertyEditorCollection;
private readonly MediaUrlGeneratorCollection _mediaUrlGenerators;
private readonly TabsAndPropertiesMapper<IMedia> _tabsAndPropertiesMapper;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public MediaMapDefinition(ICultureDictionary cultureDictionary, ILogger logger, CommonMapper commonMapper, IMediaService mediaService, IMediaTypeService mediaTypeService,
ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditorCollection, IUmbracoSettingsSection umbracoSettingsSection, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider)
public MediaMapDefinition(ICultureDictionary cultureDictionary, CommonMapper commonMapper, IMediaService mediaService, IMediaTypeService mediaTypeService,
ILocalizedTextService localizedTextService, MediaUrlGeneratorCollection mediaUrlGenerators, IUmbracoSettingsSection umbracoSettingsSection, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider)
{
_logger = logger;
_commonMapper = commonMapper;
_mediaService = mediaService;
_mediaTypeService = mediaTypeService;
_propertyEditorCollection = propertyEditorCollection;
_mediaUrlGenerators = mediaUrlGenerators;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_tabsAndPropertiesMapper = new TabsAndPropertiesMapper<IMedia>(cultureDictionary, localizedTextService, contentTypeBaseServiceProvider);
@@ -64,7 +62,7 @@ namespace Umbraco.Web.Models.Mapping
target.Id = source.Id;
target.IsChildOfListView = DetermineIsChildOfListView(source);
target.Key = source.Key;
target.MediaLink = string.Join(",", source.GetUrls(_umbracoSettingsSection.Content, _logger, _propertyEditorCollection));
target.MediaLink = string.Join(",", source.GetUrls(_umbracoSettingsSection.Content, _mediaUrlGenerators));
target.Name = source.Name;
target.Owner = _commonMapper.GetOwner(source, context);
target.ParentId = source.ParentId;