Skip to content

Commit

Permalink
Application as a super theme also for pure mvc views (#8043)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkech authored Dec 17, 2020
1 parent aa102c4 commit 877886c
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.Extensions.Hosting;
using OrchardCore.DisplayManagement.Extensions;
using OrchardCore.DisplayManagement.Razor;
using OrchardCore.Environment.Extensions;
Expand All @@ -11,10 +12,12 @@ namespace OrchardCore.DisplayManagement.LocationExpander
{
public class ThemeViewLocationExpanderProvider : IViewLocationExpanderProvider
{
private readonly IHostEnvironment _hostingEnvironment;
private readonly IExtensionManager _extensionManager;

public ThemeViewLocationExpanderProvider(IExtensionManager extensionManager)
public ThemeViewLocationExpanderProvider(IHostEnvironment hostingEnvironment, IExtensionManager extensionManager)
{
_hostingEnvironment = hostingEnvironment;
_extensionManager = extensionManager;
}

Expand Down Expand Up @@ -45,7 +48,18 @@ public virtual IEnumerable<string> ExpandViewLocations(ViewLocationExpanderConte
var currentThemeAndBaseThemesOrdered = _extensionManager
.GetFeatures(new[] { currentThemeId })
.Where(x => x.Extension.IsTheme())
.Reverse();
.Reverse()
.ToList();

// let the application acting as a super theme also for mvc views discovering.
var applicationTheme = _extensionManager
.GetFeatures()
.FirstOrDefault(x => x.Id == _hostingEnvironment.ApplicationName);

if (applicationTheme != null)
{
currentThemeAndBaseThemesOrdered.Insert(0, applicationTheme);
}

var result = new List<string>();

Expand Down

0 comments on commit 877886c

Please sign in to comment.