Files
mixtape/zero.Web/Defaults/ZeroBackofficePlugin.cs
T

145 lines
6.2 KiB
C#
Raw Normal View History

using FluentValidation;
2021-09-30 10:53:01 +02:00
using Microsoft.AspNetCore.Routing;
2020-09-10 16:12:06 +02:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
2021-09-30 10:53:01 +02:00
using Microsoft.Extensions.DependencyInjection.Extensions;
2020-12-03 15:39:54 +01:00
using zero.Core;
using zero.Core.Api;
using zero.Core.Blueprints;
2020-11-19 00:14:52 +01:00
using zero.Core.Collections;
using zero.Core.Entities;
2020-12-10 15:57:59 +01:00
using zero.Core.Integrations;
2020-11-26 16:13:00 +01:00
using zero.Core.Mails;
2020-10-06 16:00:27 +02:00
using zero.Core.Messages;
using zero.Core.Options;
using zero.Core.Plugins;
using zero.Core.Renderer;
2020-10-21 14:11:58 +02:00
using zero.Core.Routing;
2020-12-18 20:50:13 +01:00
using zero.Core.Services;
2020-12-21 00:20:28 +01:00
using zero.Core.Tokens;
2020-09-08 14:33:31 +02:00
using zero.Core.Validation;
using zero.Web.Sections;
using zero.Web.ViewHelpers;
namespace zero.Web.Defaults
{
2020-10-19 15:58:32 +02:00
internal class ZeroBackofficePlugin : ZeroPlugin
{
2020-10-19 15:58:32 +02:00
public ZeroBackofficePlugin()
{
Options.Name = "zero.Defaults";
Options.LocalizationPaths.Add("~/Resources/Localization/zero.{lang}.json");
}
public override void Configure(IZeroOptions zero)
{
2021-09-29 14:01:02 +02:00
zero.Sections.Add<DashboardSection>();
2020-10-19 15:58:32 +02:00
zero.Sections.Add<PagesSection>();
zero.Sections.Add<SpacesSection>();
zero.Sections.Add<MediaSection>();
zero.Sections.Add<SettingsSection>();
zero.Settings.AddGroup<SystemSettings>();
2021-11-11 15:39:26 +01:00
zero.Settings.AddGroup<ApplicationSettings>();
2020-10-19 15:58:32 +02:00
zero.Permissions.AddCollection<SectionPermissions>();
zero.Permissions.AddCollection<ModulePermissions>();
zero.Permissions.AddCollection<SettingsPermissions>();
zero.Permissions.AddCollection<SpacePermissions>();
2020-12-03 15:39:54 +01:00
2021-03-18 13:23:39 +01:00
zero.Icons.AddSet("feather", "Feather", "/assets/icons/feather.svg", "fth");
2020-12-04 13:18:12 +01:00
zero.Pages.Add<PageFolder>(Constants.Pages.FolderAlias, "@page.folder.name", "@page.folder.description", "fth-folder");
2021-10-06 11:47:39 +02:00
zero.Interceptors.Add<ZeroEntityRouteInterceptor>(gravity: 100);
zero.Interceptors.Add<BlueprintInterceptor>(gravity: -1);
2020-10-19 15:58:32 +02:00
}
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
2020-09-11 16:36:36 +02:00
//services.AddAll(typeof(IValidator<>), ServiceLifetime.Scoped);
2020-09-08 14:33:31 +02:00
//services.AddAll(typeof(IValidator), ServiceLifetime.Scoped);
2020-10-06 16:00:27 +02:00
services.AddSingleton<IMessageAggregator, MessageAggregator>();
services.AddScoped<IRazorRenderer, RazorRenderer>();
2021-05-04 17:23:52 +02:00
services.AddTransient<Application, Application>();
services.AddTransient<Country, Country>();
services.AddTransient<Language, Language>();
services.AddTransient<Translation, Translation>();
services.AddTransient<Page, Page>();
services.AddTransient<RecycledEntity, RecycledEntity>();
services.AddTransient<Media, Media>();
services.AddTransient<MediaFolder, MediaFolder>();
services.AddTransient<Preview, Preview>();
2021-09-30 10:53:01 +02:00
services.AddTransient<Core.Routing.Route, Core.Routing.Route>();
2021-05-04 17:23:52 +02:00
services.AddTransient<IValidator<Application>, ApplicationValidator>();
services.AddTransient<IValidator<Country>, CountryValidator>();
services.AddTransient<IValidator<MailTemplate>, MailTemplateValidator>();
services.AddTransient<IValidator<Language>, LanguageValidator>();
services.AddTransient<IValidator<Translation>, TranslationValidator>();
services.AddTransient<IValidator<Page>, PageValidator>();
services.AddTransient<IValidator<Media>, MediaValidator>();
services.AddTransient<IValidator<MediaFolder>, MediaFolderValidator>();
services.AddTransient<IValidator<BackofficeUserRole>, UserRoleValidator>();
services.AddTransient<IValidator<BackofficeUser>, BackofficeUserValidator>();
2020-09-11 16:36:36 +02:00
services.AddTransient<IApplicationsApi, ApplicationsApi>();
2020-11-19 00:14:52 +01:00
services.AddTransient<ICountriesCollection, CountriesCollection>();
services.AddTransient<ILanguagesCollection, LanguagesCollection>();
services.AddTransient<ITranslationsCollection, TranslationsCollection>();
2020-11-20 17:38:01 +01:00
services.AddTransient<IMediaCollection, MediaCollection>();
2021-10-05 14:08:39 +02:00
services.AddTransient<IPagesCollection, PagesCollection>();
services.AddTransient<IUserApi, UserApi>();
2020-09-04 11:50:22 +02:00
services.AddTransient<IPreviewApi, PreviewApi>();
services.AddTransient<IMailTemplatesCollection, MailTemplatesCollection>();
services.AddTransient<ISetupApi, SetupApi>();
services.AddTransient<ISectionsApi, SectionsApi>();
services.AddTransient<ISettingsApi, SettingsApi>();
services.AddTransient<IAuthenticationApi, AuthenticationApi>();
services.AddTransient<IUserRolesApi, UserRolesApi>();
services.AddTransient<ISpacesApi, SpacesApi>();
services.AddTransient<IPermissionsApi, PermissionsApi>();
services.AddTransient<IMediaApi, MediaApi>();
services.AddTransient<IMediaFolderApi, MediaFolderApi>();
2020-08-19 12:53:18 +02:00
services.AddTransient<IModulesApi, ModulesApi>();
services.AddTransient<IRecycleBinApi, RecycleBinApi>();
2020-10-21 14:11:58 +02:00
2020-12-22 00:57:19 +01:00
services.AddScoped<IRequestUrlResolver, RequestUrlResolver>();
2020-10-26 13:59:46 +01:00
services.AddScoped<IRoutes, Routes>();
services.AddScoped<IRouteResolver, RouteResolver>();
2021-11-10 15:53:19 +01:00
services.AddScoped<IRedirectAutomation, RedirectAutomation>();
services.AddScoped<IRouteRedirectCollection, RouteRedirectCollection>();
2020-10-26 13:59:46 +01:00
services.AddScoped<IPageUrlBuilder, PageUrlBuilder>();
services.AddScoped<IRouteProvider, PageRouteProvider>();
2021-02-10 14:53:56 +01:00
services.AddScoped<ILinks, Links>();
services.AddScoped<ILinkProvider, PageLinkProvider>();
2021-04-21 16:02:07 +02:00
services.AddScoped<ILinkProvider, RawLinkProvider>();
2020-10-26 13:59:46 +01:00
services.AddScoped<ZeroRoutesTransformer>();
2021-09-30 10:53:01 +02:00
services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, NotFoundSelectorPolicy>());
2020-11-26 16:13:00 +01:00
services.AddScoped<IMailProvider, MailProvider>();
services.AddScoped<IMailDispatcher, FileMailDispatcher>();
2020-11-26 16:13:00 +01:00
services.AddScoped<IZeroMediaHelper, ZeroMediaHelper>();
2020-12-10 15:57:59 +01:00
2021-01-15 13:56:50 +01:00
services.AddTransient<IIntegrationService, IntegrationService>();
services.AddTransient<IIntegrationsCollection, IntegrationsCollection>();
2020-12-18 20:50:13 +01:00
2021-10-13 12:47:18 +02:00
services.AddScoped<ICollectionContext, CollectionContext>();
2020-12-18 20:50:13 +01:00
services.AddScoped<ILocalizer, Localizer>();
2020-12-21 00:20:28 +01:00
services.AddScoped<IZeroTokenProvider, ZeroTokenProvider>();
2021-09-01 23:09:22 +02:00
services.AddScoped<IBackofficeSearchService, BackofficeSearchService>();
2021-10-06 11:47:39 +02:00
services.AddScoped<IBlueprintService, BlueprintService>();
services.AddScoped<BlueprintInterceptor>();
2021-10-06 11:47:39 +02:00
services.AddScoped<ZeroEntityRouteInterceptor>();
}
}
}