2018-09-20 17:22:39 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2020-09-21 13:04:57 +02:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
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-20 17:22:39 +02:00
|
|
|
|
using Umbraco.Core.Manifest;
|
|
|
|
|
|
using Umbraco.Core.Models.ContentEditing;
|
2020-01-08 14:46:20 +01:00
|
|
|
|
using Umbraco.Core.Models.Identity;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2020-09-21 13:04:57 +02:00
|
|
|
|
// get the logger factory just-in-time - see note below for manifest parser
|
|
|
|
|
|
var loggerFactory = factory.GetInstance<ILoggerFactory>();
|
2020-02-19 15:38:22 +11:00
|
|
|
|
var umbracoContextAccessor = factory.GetInstance<IUmbracoContextAccessor>();
|
2020-09-21 13:04:57 +02:00
|
|
|
|
return new ContentAppFactoryCollection(CreateItems(factory), loggerFactory.CreateLogger<ContentAppFactoryCollection>(), umbracoContextAccessor);
|
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>();
|
2020-01-08 14:46:20 +01:00
|
|
|
|
var ioHelper = factory.GetInstance<IIOHelper>();
|
|
|
|
|
|
return base.CreateItems(factory).Concat(manifestParser.Manifest.ContentApps.Select(x => new ManifestContentAppFactory(x, ioHelper)));
|
2018-09-20 17:22:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|