Files
Umbraco-CMS/src/Umbraco.Web/ContentApps/ContentAppDefinitionCollectionBuilder.cs

34 lines
1.4 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.Models.ContentEditing;
namespace Umbraco.Web.ContentApps
{
public class ContentAppDefinitionCollectionBuilder : OrderedCollectionBuilderBase<ContentAppDefinitionCollectionBuilder, ContentAppDefinitionCollection, IContentAppDefinition>
{
protected override ContentAppDefinitionCollectionBuilder This => this;
// need to inject dependencies in the collection, so override creation
public override ContentAppDefinitionCollection CreateCollection()
{
// get the logger just-in-time - see note below for manifest parser
var logger = Container.GetInstance<ILogger>();
return new ContentAppDefinitionCollection(CreateItems(), logger);
}
2018-10-08 19:27:32 +02:00
protected override IEnumerable<IContentAppDefinition> CreateItems()
{
2018-09-20 18:51:46 +02:00
// get the manifest parser just-in-time - injecting it in the ctor would mean that
// simply getting the builder in order to configure the collection, would require
// its dependencies too, and that can create cycles or other oddities
var manifestParser = Container.GetInstance<ManifestParser>();
2018-10-08 19:27:32 +02:00
return base.CreateItems().Concat(manifestParser.Manifest.ContentApps);
}
}
}