mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 11:17:28 +08:00
Recipe discovery for extensions
Setup calls RecipeManager::DiscoverRecipes Setup/Recipe contains default recipe files Unit tests for recipe discovery using embedded resources --HG-- branch : recipe
This commit is contained in:
@@ -1,28 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.FileSystems.WebSite;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Recipes.Services {
|
||||
public class RecipeManager : IRecipeManager {
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
private readonly IWebSiteFolder _webSiteFolder;
|
||||
private readonly IRecipeParser _recipeParser;
|
||||
private readonly IEnumerable<IRecipeHandler> _recipeHandlers;
|
||||
|
||||
public RecipeManager(IRecipeParser recipeParser, IEnumerable<IRecipeHandler> recipeHandlers) {
|
||||
public RecipeManager(
|
||||
IExtensionManager extensionManager,
|
||||
IWebSiteFolder webSiteFolder,
|
||||
IRecipeParser recipeParser,
|
||||
IEnumerable<IRecipeHandler> recipeHandlers) {
|
||||
_extensionManager = extensionManager;
|
||||
_webSiteFolder = webSiteFolder;
|
||||
_recipeParser = recipeParser;
|
||||
_recipeHandlers = recipeHandlers;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
ILogger Logger { get; set; }
|
||||
|
||||
public void Execute(Recipe recipe) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<Recipe> DiscoverRecipes(string extensionName) {
|
||||
throw new NotImplementedException();
|
||||
var recipes = new List<Recipe>();
|
||||
var extension = _extensionManager.GetExtension(extensionName);
|
||||
if (extension != null) {
|
||||
var recipeLocation = Path.Combine(extension.Location, extensionName, "Recipes");
|
||||
var recipeFiles = _webSiteFolder.ListFiles(recipeLocation, true);
|
||||
recipes.AddRange(
|
||||
from recipeFile in recipeFiles
|
||||
where recipeFile.EndsWith(".recipe.xml")
|
||||
select _recipeParser.ParseRecipe(_webSiteFolder.ReadFile(recipeFile)));
|
||||
}
|
||||
else {
|
||||
Logger.Error("Could not discover recipes because module '{0}' was not found.", extensionName);
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Recipes.Services {
|
||||
@@ -11,7 +10,7 @@ namespace Orchard.Recipes.Services {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public Recipe ParseRecipe(string recipeText) {
|
||||
throw new NotImplementedException();
|
||||
return new Recipe();
|
||||
}
|
||||
}
|
||||
}
|
@@ -76,6 +76,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\synchronizing.gif" />
|
||||
<Content Include="Recipes\blog.recipe.xml" />
|
||||
<Content Include="Recipes\cms.recipe.xml" />
|
||||
<Content Include="Recipes\minimal.recipe.xml" />
|
||||
<Content Include="Scripts\setup.js" />
|
||||
<Content Include="Views\Setup\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
|
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Web;
|
||||
@@ -23,6 +24,8 @@ using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Indexing;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
@@ -204,6 +207,9 @@ namespace Orchard.Setup.Services {
|
||||
}
|
||||
|
||||
private void CreateTenantData(SetupContext context, IWorkContextScope environment) {
|
||||
var recipeManager = environment.Resolve<IRecipeManager>();
|
||||
var setupRecipes = recipeManager.DiscoverRecipes("Orchard.Setup");
|
||||
|
||||
// create superuser
|
||||
var membershipService = environment.Resolve<IMembershipService>();
|
||||
var user =
|
||||
|
Reference in New Issue
Block a user