mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 20:13:52 +08:00
Refactored IShellSettingsEventHandler to prepare a relocation to DefaultOrchardHost
Need some autofac tweeks as ShellSettingsManager can't have a dependency on, and DefaultOrchardHost can't implement IEventHandler Currently modified IOrchardHost by adding InvalidateShells() which is called by TenantService. To do: Remove InvalidateShell, make DefaultOrchardHost implement IShellSettingsEventHandler, and make ShellSettingsManager fire the events --HG-- branch : dev
This commit is contained in:
@@ -6,22 +6,14 @@ using Orchard.Environment;
|
||||
namespace Orchard.MultiTenancy.Services {
|
||||
public class ShellSettingsEventHandler : IShellSettingsEventHandler, IDependency {
|
||||
|
||||
private readonly IRunningShellTable _runningShellTable;
|
||||
private readonly IOrchardHost _orchardHost;
|
||||
|
||||
public ShellSettingsEventHandler(IRunningShellTable runningShellTable) {
|
||||
_runningShellTable = runningShellTable;
|
||||
public ShellSettingsEventHandler(IOrchardHost orchardHost) {
|
||||
_orchardHost = orchardHost;
|
||||
}
|
||||
|
||||
public void Created(ShellSettings settings) {
|
||||
_runningShellTable.Add(settings);
|
||||
}
|
||||
|
||||
public void Deleted(ShellSettings settings) {
|
||||
_runningShellTable.Remove(settings);
|
||||
}
|
||||
|
||||
public void Updated(ShellSettings settings) {
|
||||
_runningShellTable.Update(settings);
|
||||
public void Saved(ShellSettings settings) {
|
||||
_orchardHost.InvalidateShells();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace Orchard.MultiTenancy.Services {
|
||||
|
||||
public void CreateTenant(ShellSettings settings) {
|
||||
_shellSettingsManager.SaveSettings(settings);
|
||||
_shellSettingsEventHandler.Created(settings);
|
||||
_shellSettingsEventHandler.Saved(settings);
|
||||
}
|
||||
|
||||
public void UpdateTenant(ShellSettings settings) {
|
||||
var tenant = GetTenants().FirstOrDefault(ss => ss.Name == settings.Name);
|
||||
if ( tenant != null ) {
|
||||
_shellSettingsManager.SaveSettings(settings);
|
||||
_shellSettingsEventHandler.Updated(settings);
|
||||
_shellSettingsEventHandler.Saved(settings);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using Orchard.Logging;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.ViewEngines;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Environment {
|
||||
public class DefaultOrchardHost : IOrchardHost {
|
||||
@@ -136,12 +137,12 @@ namespace Orchard.Environment {
|
||||
}
|
||||
|
||||
public void Process(string messageName, IDictionary<string, string> eventData) {
|
||||
if (messageName == "ShellSettings_Saved") {
|
||||
_current = null;
|
||||
}
|
||||
else if (messageName == "ShellDescriptor_Changed") {
|
||||
if (messageName == "ShellDescriptor_Changed") {
|
||||
_current = null;
|
||||
}
|
||||
}
|
||||
public void InvalidateShells() {
|
||||
_current = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,10 @@ namespace Orchard.Environment {
|
||||
/// Services may be resolved from within this instance to configure and initialize it's storage.
|
||||
/// </summary>
|
||||
IStandaloneEnvironment CreateStandaloneEnvironment(ShellSettings shellSettings);
|
||||
|
||||
/// <summary>
|
||||
/// Resets Shell settings
|
||||
/// </summary>
|
||||
void InvalidateShells();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Orchard.Events {
|
||||
public interface IShellSettingsEventHandler : IEventHandler {
|
||||
void Created(ShellSettings settings);
|
||||
void Deleted(ShellSettings settings);
|
||||
void Updated(ShellSettings settings);
|
||||
void Saved(ShellSettings settings);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user