#5056: Added Export Features recipe step.

Fixes #5056
This commit is contained in:
Sipke Schoorstra
2015-07-09 12:29:05 +01:00
parent 41b245560c
commit 76132f2691
4 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Orchard.Environment.Features;
using Orchard.Events;
namespace Orchard.Modules.ImportExport {
public interface IExportEventHandler : IEventHandler {
void Exporting(dynamic context);
void Exported(dynamic context);
}
public class FeaturesExportHandler : IExportEventHandler {
private readonly IFeatureManager _featureManager;
public FeaturesExportHandler(IFeatureManager featureManager) {
_featureManager = featureManager;
}
public void Exporting(dynamic context) {
if (!((IEnumerable<string>)context.ExportOptions.CustomSteps).Contains("Features")) {
return;
}
var enabledFeatures = _featureManager.GetEnabledFeatures();
var root = new XElement("Feature", new XAttribute("enable", String.Join(", ", enabledFeatures.Select(x => x.Id))));
context.Document.Element("Orchard").Add(root);
}
public void Exported(dynamic context) {
}
}
}

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
using Orchard.Events;
namespace Orchard.Modules.ImportExport {
public interface ICustomExportStep : IEventHandler {
void Register(IList<string> steps);
}
public class FeaturesStep : ICustomExportStep {
public void Register(IList<string> steps) {
steps.Add("Features");
}
}
}

View File

@@ -7,3 +7,13 @@ OrchardVersion: 1.9
Description: The Modules module enables the administrator of the site to manage the installed modules as well as activate and de-activate features.
FeatureDescription: Standard module and feature management.
Category: Core
Features:
Orchard.Modules:
Description: Standard module and feature management.
Dependencies: Orchard.jQuery
Category: Core
Orchard.Modules.ExportFeatures:
Name: Export Features
Description: Provides feature export capability.
Category: Deployment
Dependencies: Orchard.ImportExport

View File

@@ -25,6 +25,7 @@
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -64,12 +65,15 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Data\Migration\DataMigrationNotificationProvider.cs" />
<Compile Include="Events\IExtensionDisplayEventHandler.cs" />
<Compile Include="ImportExport\FeaturesStep.cs" />
<Compile Include="ImportExport\FeaturesExportHandler.cs" />
<Compile Include="ResourceManifest.cs" />
<Compile Include="Commands\FeatureCommands.cs" />
<Compile Include="Controllers\AdminController.cs" />