2020-10-30 11:16:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
using System.Linq;
|
2020-10-30 11:16:17 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2020-09-21 13:04:57 +02:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2021-02-18 11:06:02 +01:00
|
|
|
|
using Umbraco.Cms.Core.Composing;
|
|
|
|
|
|
using Umbraco.Cms.Core.IO;
|
|
|
|
|
|
using Umbraco.Cms.Core.Manifest;
|
|
|
|
|
|
using Umbraco.Cms.Core.Models.ContentEditing;
|
|
|
|
|
|
using Umbraco.Cms.Core.Security;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
|
namespace Umbraco.Cms.Core.ContentApps
|
2018-09-20 17:22:39 +02:00
|
|
|
|
{
|
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
|
2020-10-30 11:16:17 +00:00
|
|
|
|
public override ContentAppFactoryCollection CreateCollection(IServiceProvider 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
|
2020-10-27 10:53:01 +00:00
|
|
|
|
var loggerFactory = factory.GetRequiredService<ILoggerFactory>();
|
2020-11-24 12:52:48 +01:00
|
|
|
|
var backOfficeSecurityAccessor = factory.GetRequiredService<IBackOfficeSecurityAccessor>();
|
|
|
|
|
|
return new ContentAppFactoryCollection(CreateItems(factory), loggerFactory.CreateLogger<ContentAppFactoryCollection>(), backOfficeSecurityAccessor);
|
2018-09-24 09:34:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-30 11:16:17 +00:00
|
|
|
|
protected override IEnumerable<IContentAppFactory> CreateItems(IServiceProvider 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
|
2020-10-27 10:53:01 +00:00
|
|
|
|
var manifestParser = factory.GetRequiredService<IManifestParser>();
|
|
|
|
|
|
var ioHelper = factory.GetRequiredService<IIOHelper>();
|
2020-01-08 14:46:20 +01:00
|
|
|
|
return base.CreateItems(factory).Concat(manifestParser.Manifest.ContentApps.Select(x => new ManifestContentAppFactory(x, ioHelper)));
|
2018-09-20 17:22:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|