TagPatterns use event bus

--HG--
branch : autoroute
This commit is contained in:
randompete
2012-01-20 04:59:48 +00:00
parent ce4aa0f3e3
commit 91fa602037
@@ -6,9 +6,15 @@ using Orchard.Tags.Services;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Tags.Models; using Orchard.Tags.Models;
using System.Web.Routing; using System.Web.Routing;
using Orchard.Events;
namespace Orchard.Tags.Providers { namespace Orchard.Tags.Providers {
public class TagPatterns {
public interface IRoutePatternProvider : IEventHandler {
void Describe(dynamic describe);
void Suggest(dynamic suggest);
}
public class TagPatterns : IRoutePatternProvider {
private readonly ITagService _tagService; private readonly ITagService _tagService;
@@ -27,7 +33,7 @@ namespace Orchard.Tags.Providers {
.Pattern("View", T("View tagged content"), T("Tagged content will be listed on this Url for each tag"), (Func<TagRecord, RouteValueDictionary>)GetRouteValues); .Pattern("View", T("View tagged content"), T("Tagged content will be listed on this Url for each tag"), (Func<TagRecord, RouteValueDictionary>)GetRouteValues);
} }
protected RouteValueDictionary GetRouteValues(TagRecord tag) { public RouteValueDictionary GetRouteValues(TagRecord tag) {
return new RouteValueDictionary(new{ return new RouteValueDictionary(new{
area = "Orchard.Tags", area = "Orchard.Tags",
controller = "Home", controller = "Home",
@@ -36,7 +42,7 @@ namespace Orchard.Tags.Providers {
}); });
} }
protected RouteValueDictionary GetTagsRouteValues(TagRecord tag) { public RouteValueDictionary GetTagsRouteValues(TagRecord tag) {
return new RouteValueDictionary(new { return new RouteValueDictionary(new {
area = "Orchard.Tags", area = "Orchard.Tags",
controller = "Home", controller = "Home",
@@ -44,11 +50,11 @@ namespace Orchard.Tags.Providers {
}); });
} }
protected string GetId(TagRecord tag) { public string GetId(TagRecord tag) {
return tag.Id.ToString(); return tag.Id.ToString();
} }
protected TagRecord GetTag(string id) { public TagRecord GetTag(string id) {
return _tagService.GetTag(Convert.ToInt32(id)); return _tagService.GetTag(Convert.ToInt32(id));
} }