2018-09-20 17:22:39 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2019-02-14 09:15:47 +01:00
|
|
|
|
using Umbraco.Core;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
using Umbraco.Core.Composing;
|
2019-11-08 10:57:24 +01:00
|
|
|
|
using Umbraco.Core.IO;
|
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
|
|
|
|
|
|
{
|
2018-12-07 14:05:47 +01:00
|
|
|
|
public class ContentAppFactoryCollectionBuilder : OrderedCollectionBuilderBase<ContentAppFactoryCollectionBuilder, ContentAppFactoryCollection, IContentAppFactory>
|
2018-09-20 17:22:39 +02:00
|
|
|
|
{
|
2018-12-07 14:05:47 +01:00
|
|
|
|
protected override ContentAppFactoryCollectionBuilder This => this;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
|
2018-09-24 09:34:25 +02:00
|
|
|
|
// need to inject dependencies in the collection, so override creation
|
2018-12-07 16:12:08 +01:00
|
|
|
|
public override ContentAppFactoryCollection CreateCollection(IFactory factory)
|
2018-09-24 09:34:25 +02:00
|
|
|
|
{
|
|
|
|
|
|
// get the logger just-in-time - see note below for manifest parser
|
2018-11-28 11:05:41 +01:00
|
|
|
|
var logger = factory.GetInstance<ILogger>();
|
2018-09-24 09:34:25 +02:00
|
|
|
|
|
2018-12-07 16:12:08 +01:00
|
|
|
|
return new ContentAppFactoryCollection(CreateItems(factory), logger);
|
2018-09-24 09:34:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-07 16:12:08 +01:00
|
|
|
|
protected override IEnumerable<IContentAppFactory> CreateItems(IFactory factory)
|
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
|
2019-11-06 13:35:34 +01:00
|
|
|
|
var manifestParser = factory.GetInstance<IManifestParser>();
|
2018-09-20 18:51:46 +02:00
|
|
|
|
|
2019-11-08 10:57:24 +01:00
|
|
|
|
return base.CreateItems(factory).Concat(manifestParser.Manifest.ContentApps.Select(x => new ManifestContentAppFactory(x, Current.IOHelper)));
|
2018-09-20 17:22:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|