Skip to content
Permalink
Browse files

# 3660 Added supporting custom validation logic during plugin uninst…

…allation
  • Loading branch information...
skoshelev committed Apr 25, 2019
1 parent ad75f83 commit b4488ebc7f0c797137fb8a4a6f376efe3f18e295
@@ -1,4 +1,6 @@
namespace Nop.Services.Plugins
using System;

namespace Nop.Services.Plugins
{
/// <summary>
/// Base plugin
@@ -31,5 +33,15 @@ public virtual void Install()
public virtual void Uninstall()
{
}

/// <summary>
/// Prepare plugin to the uninstallation
/// </summary>
public virtual void PreparePluginToUninstall()
{
//any can put any custom validation logic here
//throw an exception if this plugin cannot be uninstalled
//for example, requires some other certain plugins to be uninstalled first
}
}
}
@@ -25,5 +25,10 @@ public interface IPlugin
/// Uninstall plugin
/// </summary>
void Uninstall();

/// <summary>
/// Prepare plugin to the uninstallation
/// </summary>
void PreparePluginToUninstall();
}
}
@@ -262,6 +262,9 @@ public virtual void PreparePluginToUninstall(string systemName)
if (_pluginsInfo.PluginNamesToUninstall.Contains(systemName))
return;

var plugin = GetPluginDescriptorBySystemName<IPlugin>(systemName)?.Instance<IPlugin>();
plugin?.PreparePluginToUninstall();

_pluginsInfo.PluginNamesToUninstall.Add(systemName);
_pluginsInfo.Save();
}

0 comments on commit b4488eb

Please sign in to comment.
You can’t perform that action at this time.