Some work on making the route part more container aware

- still needs some work in the Slugify method (for client slugification)
- also a container path placeholder...

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-13 01:52:53 -08:00
parent 2e2820de1f
commit 036033116f
9 changed files with 153 additions and 109 deletions

View File

@@ -6,14 +6,21 @@ using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Containers.Models;
using Orchard.Core.Containers.ViewModels;
using Orchard.Core.Routable.Models;
using Orchard.Core.Routable.Services;
using Orchard.Localization;
using Orchard.UI.Notify;
namespace Orchard.Core.Containers.Drivers {
public class ContainablePartDriver : ContentPartDriver<ContainablePart> {
private readonly IContentManager _contentManager;
private readonly IRoutableService _routableService;
private readonly IOrchardServices _services;
public ContainablePartDriver(IContentManager contentManager) {
public ContainablePartDriver(IContentManager contentManager, IRoutableService routableService, IOrchardServices services) {
_contentManager = contentManager;
_routableService = routableService;
_services = services;
T = NullLocalizer.Instance;
}
@@ -39,6 +46,18 @@ namespace Orchard.Core.Containers.Drivers {
updater.TryUpdateModel(model, "Containable", null, null);
if (oldContainerId != model.ContainerId) {
commonPart.Container = _contentManager.Get(model.ContainerId, VersionOptions.Latest);
// reprocess slug
var routable = part.As<IRoutableAspect>();
_routableService.ProcessSlug(part.As<IRoutableAspect>());
if (!_routableService.ProcessSlug(routable)) {
var existingConflict = _services.Notifier.List().FirstOrDefault(n => n.Message.TextHint == "Slugs in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"");
if (existingConflict != null)
existingConflict.Message = T("Slugs in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
routable.Slug, routable.GetEffectiveSlug(), routable.ContentItem.ContentType);
else
_services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
routable.Slug, routable.GetEffectiveSlug(), routable.ContentItem.ContentType));
}
}
}