This commit is contained in:
Stephan
2018-12-07 14:05:47 +01:00
parent 6dad124d5b
commit 1eee6dfb2f
13 changed files with 23 additions and 52 deletions

View File

@@ -1,16 +0,0 @@
using System;
using Newtonsoft.Json.Linq;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.Serialization;
namespace Umbraco.Core.Manifest
{
/// <summary>
/// Implements a json read converter for <see cref="ManifestContentAppDefinition"/>.
/// </summary>
internal class ContentAppDefinitionConverter : JsonReadConverter<ManifestContentAppDefinition>
{
protected override ManifestContentAppDefinition Create(Type objectType, string path, JObject jObject)
=> new ManifestContentAppDefinition();
}
}

View File

@@ -26,13 +26,12 @@ namespace Umbraco.Core.Manifest
// ]
/// <summary>
/// Represents a content app definition, parsed from a manifest.
/// Represents a content app factory, for content apps parsed from the manifest.
/// </summary>
public class ManifestContentAppFactory : IContentAppFactory
{
private readonly ManifestContentAppDefinition _definition;
public ManifestContentAppFactory(ManifestContentAppDefinition definition)
{
_definition = definition;

View File

@@ -153,7 +153,6 @@ namespace Umbraco.Core.Manifest
var manifest = JsonConvert.DeserializeObject<PackageManifest>(text,
new DataEditorConverter(_logger),
new ValueValidatorConverter(_validators),
new ContentAppDefinitionConverter(),
new DashboardAccessRuleConverter());
// scripts and stylesheets are raw string, must process here

View File

@@ -1,13 +1,10 @@
using System.Collections.Generic;
using Umbraco.Core.Manifest;
using Umbraco.Core.Models.Membership;
namespace Umbraco.Core.Models.ContentEditing
{
/// <summary>
/// Represents a content app definition.
/// Represents a content app factory.
/// </summary>
public interface IContentAppFactory
{

View File

@@ -334,7 +334,6 @@
<Compile Include="Logging\Serilog\Enrichers\HttpSessionIdEnricher.cs" />
<Compile Include="Logging\Serilog\LoggerConfigExtensions.cs" />
<Compile Include="Logging\Serilog\Enrichers\Log4NetLevelMapperEnricher.cs" />
<Compile Include="Manifest\ContentAppDefinitionConverter.cs" />
<Compile Include="Manifest\DashboardAccessRuleConverter.cs" />
<Compile Include="Manifest\ManifestContentAppDefinition.cs" />
<Compile Include="Manifest\ManifestContentAppFactory.cs" />

View File

@@ -213,7 +213,7 @@ namespace Umbraco.Tests.Testing
Container.RegisterSingleton<IMediaPathScheme, OriginalMediaPathScheme>();
// register empty content apps collection
Container.RegisterCollectionBuilder<ContentAppDefinitionCollectionBuilder>();
Container.RegisterCollectionBuilder<ContentAppFactoryCollectionBuilder>();
}
protected virtual void ComposeCacheHelper()

View File

@@ -40,8 +40,8 @@ namespace Umbraco.Core.Components
/// </summary>
/// <param name="composition">The composition.</param>
/// <returns></returns>
public static ContentAppDefinitionCollectionBuilder ContentApps(this Composition composition)
=> composition.Container.GetInstance<ContentAppDefinitionCollectionBuilder>();
public static ContentAppFactoryCollectionBuilder ContentApps(this Composition composition)
=> composition.Container.GetInstance<ContentAppFactoryCollectionBuilder>();
/// <summary>
/// Gets the content finders collection builder.

View File

@@ -1,21 +1,18 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.Models.Membership;
namespace Umbraco.Web.ContentApps
{
public class ContentAppDefinitionCollection : BuilderCollectionBase<IContentAppFactory>
public class ContentAppFactoryCollection : BuilderCollectionBase<IContentAppFactory>
{
private readonly ILogger _logger;
private readonly IContentAppFactory _factory;
public ContentAppDefinitionCollection(IEnumerable<IContentAppFactory> items, ILogger logger)
public ContentAppFactoryCollection(IEnumerable<IContentAppFactory> items, ILogger logger)
: base(items)
{
_logger = logger;
@@ -35,10 +32,8 @@ namespace Umbraco.Web.ContentApps
{
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;
@@ -55,7 +50,7 @@ namespace Umbraco.Web.ContentApps
// 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.Warn<ContentAppDefinitionCollection>("Duplicate content app aliases found: {DuplicateAliases}", string.Join(",", dups));
_logger.Warn<ContentAppFactoryCollection>("Duplicate content app aliases found: {DuplicateAliases}", string.Join(",", dups));
}
return apps;

View File

@@ -5,26 +5,24 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.Services;
namespace Umbraco.Web.ContentApps
{
public class ContentAppDefinitionCollectionBuilder : OrderedCollectionBuilderBase<ContentAppDefinitionCollectionBuilder, ContentAppDefinitionCollection, IContentAppFactory>
public class ContentAppFactoryCollectionBuilder : OrderedCollectionBuilderBase<ContentAppFactoryCollectionBuilder, ContentAppFactoryCollection, IContentAppFactory>
{
public ContentAppDefinitionCollectionBuilder(IServiceContainer container)
public ContentAppFactoryCollectionBuilder(IServiceContainer container)
: base(container)
{
}
{ }
protected override ContentAppDefinitionCollectionBuilder This => this;
protected override ContentAppFactoryCollectionBuilder This => this;
// need to inject dependencies in the collection, so override creation
public override ContentAppDefinitionCollection CreateCollection()
public override ContentAppFactoryCollection CreateCollection()
{
// get the logger just-in-time - see note below for manifest parser
var logger = Container.GetInstance<ILogger>();
return new ContentAppDefinitionCollection(CreateItems(), logger);
return new ContentAppFactoryCollection(CreateItems(), logger);
}
protected override IEnumerable<IContentAppFactory> CreateItems(params object[] args)
@@ -34,7 +32,7 @@ namespace Umbraco.Web.ContentApps
// its dependencies too, and that can create cycles or other oddities
var manifestParser = Container.GetInstance<ManifestParser>();
return base.CreateItems(args).Concat(manifestParser.Manifest.ContentApps.Select(x=>new ManifestContentAppFactory(x)));
return base.CreateItems(args).Concat(manifestParser.Manifest.ContentApps.Select(x => new ManifestContentAppFactory(x)));
}
}
}

View File

@@ -11,9 +11,9 @@ namespace Umbraco.Web.Models.Mapping
// maps ContentApps when mapping IContent to ContentItemDisplay
internal class ContentAppResolver : IValueResolver<IContent, ContentItemDisplay, IEnumerable<ContentApp>>
{
private readonly ContentAppDefinitionCollection _contentAppDefinitions;
private readonly ContentAppFactoryCollection _contentAppDefinitions;
public ContentAppResolver(ContentAppDefinitionCollection contentAppDefinitions)
public ContentAppResolver(ContentAppFactoryCollection contentAppDefinitions)
{
_contentAppDefinitions = contentAppDefinitions;
}

View File

@@ -11,9 +11,9 @@ namespace Umbraco.Web.Models.Mapping
// maps ContentApps when mapping IMedia to MediaItemDisplay
internal class MediaAppResolver : IValueResolver<IMedia, MediaItemDisplay, IEnumerable<ContentApp>>
{
private readonly ContentAppDefinitionCollection _contentAppDefinitions;
private readonly ContentAppFactoryCollection _contentAppDefinitions;
public MediaAppResolver(ContentAppDefinitionCollection contentAppDefinitions)
public MediaAppResolver(ContentAppFactoryCollection contentAppDefinitions)
{
_contentAppDefinitions = contentAppDefinitions;
}

View File

@@ -208,7 +208,7 @@ namespace Umbraco.Web.Runtime
composition.Container.RegisterSingleton<IPublishedValueFallback, PublishedValueFallback>();
// register known content apps
composition.Container.RegisterCollectionBuilder<ContentAppDefinitionCollectionBuilder>()
composition.Container.RegisterCollectionBuilder<ContentAppFactoryCollectionBuilder>()
.Append<ListViewContentAppFactory>()
.Append<ContentEditorContentAppFactory>()
.Append<ContentInfoContentAppFactory>();

View File

@@ -156,8 +156,8 @@
<Compile Include="Models\ContentEditing\SearchResults.cs" />
<Compile Include="Models\ContentEditing\UnpublishContent.cs" />
<Compile Include="Models\Mapping\MappingOperationOptionsExtensions.cs" />
<Compile Include="ContentApps\ContentAppDefinitionCollection.cs" />
<Compile Include="ContentApps\ContentAppDefinitionCollectionBuilder.cs" />
<Compile Include="ContentApps\ContentAppFactoryCollection.cs" />
<Compile Include="ContentApps\ContentAppFactoryCollectionBuilder.cs" />
<Compile Include="ContentApps\ContentEditorContentAppFactory.cs" />
<Compile Include="ContentApps\ContentInfoContentAppFactory.cs" />
<Compile Include="Models\Mapping\ScheduledPublishDateResolver.cs" />