Skip to content

Commit

Permalink
Decouple OC.Tenants from an ISiteService registration (OrchardCMS#12165)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkech authored Aug 15, 2022
1 parent e158e59 commit 4f66e9f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using OrchardCore.Data;
using OrchardCore.DisplayManagement;
Expand Down Expand Up @@ -37,7 +38,6 @@ public class AdminController : Controller
private readonly IDataProtectionProvider _dataProtectorProvider;
private readonly IClock _clock;
private readonly INotifier _notifier;
private readonly ISiteService _siteService;
private readonly ITenantValidator _tenantValidator;

private readonly dynamic New;
Expand All @@ -55,7 +55,6 @@ public AdminController(
IDataProtectionProvider dataProtectorProvider,
IClock clock,
INotifier notifier,
ISiteService siteService,
ITenantValidator tenantValidator,
IShapeFactory shapeFactory,
IStringLocalizer<AdminController> stringLocalizer,
Expand All @@ -71,7 +70,6 @@ public AdminController(
_dataProtectorProvider = dataProtectorProvider;
_clock = clock;
_notifier = notifier;
_siteService = siteService;
_tenantValidator = tenantValidator;

New = shapeFactory;
Expand All @@ -94,8 +92,15 @@ public async Task<IActionResult> Index(TenantIndexOptions options, PagerParamete
var allSettings = _shellHost.GetAllSettings().OrderBy(s => s.Name);
var dataProtector = _dataProtectorProvider.CreateProtector("Tokens").ToTimeLimitedDataProtector();

var siteSettings = await _siteService.GetSiteSettingsAsync();
var pager = new Pager(pagerParameters, siteSettings.PageSize);
var pageSize = 10;
var siteService = HttpContext.RequestServices.GetService<ISiteService>();
if (siteService != null)
{
var siteSettings = await siteService.GetSiteSettingsAsync();
pageSize = siteSettings.PageSize;
}

var pager = new Pager(pagerParameters, pageSize);

var entries = allSettings.Select(x =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Newtonsoft.Json;
using OrchardCore.Admin;
Expand All @@ -28,7 +29,6 @@ public class FeatureProfilesController : Controller
{
private readonly IAuthorizationService _authorizationService;
private readonly FeatureProfilesManager _featureProfilesManager;
private readonly ISiteService _siteService;
private readonly INotifier _notifier;
private readonly IStringLocalizer S;
private readonly IHtmlLocalizer H;
Expand All @@ -37,7 +37,6 @@ public class FeatureProfilesController : Controller
public FeatureProfilesController(
IAuthorizationService authorizationService,
FeatureProfilesManager featueProfilesManager,
ISiteService siteService,
INotifier notifier,
IShapeFactory shapeFactory,
IStringLocalizer<FeatureProfilesController> stringLocalizer,
Expand All @@ -46,7 +45,6 @@ IHtmlLocalizer<FeatureProfilesController> htmlLocalizer
{
_authorizationService = authorizationService;
_featureProfilesManager = featueProfilesManager;
_siteService = siteService;
_notifier = notifier;
New = shapeFactory;
S = stringLocalizer;
Expand All @@ -60,8 +58,15 @@ public async Task<IActionResult> Index(ContentOptions options, PagerParameters p
return Forbid();
}

var siteSettings = await _siteService.GetSiteSettingsAsync();
var pager = new Pager(pagerParameters, siteSettings.PageSize);
var pageSize = 10;
var siteService = HttpContext.RequestServices.GetService<ISiteService>();
if (siteService != null)
{
var siteSettings = await siteService.GetSiteSettingsAsync();
pageSize = siteSettings.PageSize;
}

var pager = new Pager(pagerParameters, pageSize);
var featureProfilesDocument = await _featureProfilesManager.GetFeatureProfilesDocumentAsync();

var featureProfiles = featureProfilesDocument.FeatureProfiles.ToList();
Expand Down

0 comments on commit 4f66e9f

Please sign in to comment.