mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 21:13:35 +08:00
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:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user