Remove static methods and events from EmailSender

This commit is contained in:
Kenn Jacobsen
2021-02-25 15:08:56 +01:00
parent 01bf937497
commit 3769e8108c
6 changed files with 46 additions and 103 deletions

View File

@@ -5,10 +5,9 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Mail;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.Entities;
@@ -16,7 +15,6 @@ using Umbraco.Cms.Core.Models.Trees;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Infrastructure;
using Umbraco.Cms.Infrastructure.Search;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Authorization;
@@ -34,7 +32,6 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
{
private readonly UmbracoTreeSearcher _treeSearcher;
private readonly ActionCollection _actions;
private readonly GlobalSettings _globalSettings;
private readonly IMenuItemCollectionFactory _menuItemCollectionFactory;
private readonly IBackOfficeSecurityAccessor _backofficeSecurityAccessor;
private readonly IContentService _contentService;
@@ -42,6 +39,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
private readonly IPublicAccessService _publicAccessService;
private readonly IUserService _userService;
private readonly ILocalizationService _localizationService;
private readonly IEmailSender _emailSender;
public ContentTreeController(
ILocalizedTextService localizedTextService,
@@ -55,15 +53,14 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
IDataTypeService dataTypeService,
UmbracoTreeSearcher treeSearcher,
ActionCollection actions,
IOptions<GlobalSettings> globalSettings,
IContentService contentService,
IPublicAccessService publicAccessService,
ILocalizationService localizationService)
ILocalizationService localizationService,
IEmailSender emailSender)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, entityService, backofficeSecurityAccessor, logger, actionCollection, userService, dataTypeService)
{
_treeSearcher = treeSearcher;
_actions = actions;
_globalSettings = globalSettings.Value;
_menuItemCollectionFactory = menuItemCollectionFactory;
_backofficeSecurityAccessor = backofficeSecurityAccessor;
_contentService = contentService;
@@ -71,6 +68,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
_publicAccessService = publicAccessService;
_userService = userService;
_localizationService = localizationService;
_emailSender = emailSender;
}
protected override int RecycleBinId => Constants.System.RecycleBinContent;
@@ -275,7 +273,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
AddActionNode<ActionRights>(item, menu, opensDialog: true);
AddActionNode<ActionProtect>(item, menu, true, opensDialog: true);
if (EmailSender.CanSendRequiredEmail(_globalSettings))
if (_emailSender.CanSendRequiredEmail())
{
menu.Items.Add(new MenuItem("notify", LocalizedTextService)
{