2018-09-20 17:22:39 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Umbraco.Core.Composing;
|
2018-09-24 09:34:25 +02:00
|
|
|
|
using Umbraco.Core.Logging;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
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;
|
|
|
|
|
|
|
2018-09-24 09:34:25 +02:00
|
|
|
|
// 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 17:22:39 +02:00
|
|
|
|
{
|
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);
|
2018-09-20 17:22:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|