* Rename Umbraco.Core namespace to Umbraco.Cms.Core * Move extension methods in core project to Umbraco.Extensions * Move extension methods in core project to Umbraco.Extensions * Rename Umbraco.Examine namespace to Umbraco.Cms.Examine * Move examine extensions to Umbraco.Extensions namespace * Reflect changed namespaces in Builder and fix unit tests * Adjust namespace in Umbraco.ModelsBuilder.Embedded * Adjust namespace in Umbraco.Persistence.SqlCe * Adjust namespace in Umbraco.PublishedCache.NuCache * Align namespaces in Umbraco.Web.BackOffice * Align namespaces in Umbraco.Web.Common * Ensure that SqlCeSupport is still enabled after changing the namespace * Align namespaces in Umbraco.Web.Website * Align namespaces in Umbraco.Web.UI.NetCore * Align namespaces in Umbraco.Tests.Common * Align namespaces in Umbraco.Tests.UnitTests * Align namespaces in Umbraco.Tests.Integration * Fix errors caused by changed namespaces * Fix integration tests * Undo the Umbraco.Examine.Lucene namespace change This breaks integration tests on linux, since the namespace wont exists there because it's only used on windows. * Fix merge * Fix Merge
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.Extensions.Logging;
|
|
using Umbraco.Cms.Core.Composing;
|
|
using Umbraco.Cms.Core.Models.ContentEditing;
|
|
using Umbraco.Cms.Core.Models.Membership;
|
|
using Umbraco.Cms.Core.Security;
|
|
using Umbraco.Extensions;
|
|
|
|
namespace Umbraco.Cms.Core.ContentApps
|
|
{
|
|
public class ContentAppFactoryCollection : BuilderCollectionBase<IContentAppFactory>
|
|
{
|
|
private readonly ILogger<ContentAppFactoryCollection> _logger;
|
|
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
|
|
|
public ContentAppFactoryCollection(IEnumerable<IContentAppFactory> items, ILogger<ContentAppFactoryCollection> logger, IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
|
|
: base(items)
|
|
{
|
|
_logger = logger;
|
|
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
|
}
|
|
|
|
private IEnumerable<IReadOnlyUserGroup> GetCurrentUserGroups()
|
|
{
|
|
var currentUser = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser;
|
|
return currentUser == null
|
|
? Enumerable.Empty<IReadOnlyUserGroup>()
|
|
: currentUser.Groups;
|
|
|
|
}
|
|
|
|
public IEnumerable<ContentApp> GetContentAppsFor(object o, IEnumerable<IReadOnlyUserGroup> userGroups=null)
|
|
{
|
|
var roles = GetCurrentUserGroups();
|
|
|
|
var apps = this.Select(x => x.GetContentAppFor(o, roles)).WhereNotNull().OrderBy(x => x.Weight).ToList();
|
|
|
|
var aliases = new HashSet<string>();
|
|
List<string> dups = null;
|
|
|
|
foreach (var app in apps)
|
|
{
|
|
if (aliases.Contains(app.Alias))
|
|
(dups ?? (dups = new List<string>())).Add(app.Alias);
|
|
else
|
|
aliases.Add(app.Alias);
|
|
}
|
|
|
|
if (dups != null)
|
|
{
|
|
// dying is not user-friendly, so let's write to log instead, and wish people read logs...
|
|
|
|
//throw new InvalidOperationException($"Duplicate content app aliases found: {string.Join(",", dups)}");
|
|
_logger.LogWarning("Duplicate content app aliases found: {DuplicateAliases}", string.Join(",", dups));
|
|
}
|
|
|
|
return apps;
|
|
}
|
|
}
|
|
}
|