Moving Orchard.Core/Common handlers into Models

--HG--
branch : dev
rename : src/Orchard.Web/Core/Common/Providers/BodyAspectHandler.cs => src/Orchard.Web/Core/Common/Models/BodyAspectHandler.cs
rename : src/Orchard.Web/Core/Common/Providers/CommonAspectHandler.cs => src/Orchard.Web/Core/Common/Models/CommonAspectHandler.cs
This commit is contained in:
Nathan Heskew
2010-03-03 00:40:32 -08:00
parent c281c2a313
commit 98b483f827
6 changed files with 27 additions and 39 deletions

View File

@@ -1,14 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using Autofac.Builder; using Autofac.Builder;
using JetBrains.Annotations; using JetBrains.Annotations;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Aspects;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
using Orchard.Core.Common.Providers;
using Orchard.Core.Common.Records; using Orchard.Core.Common.Records;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;

View File

@@ -2,10 +2,10 @@ using Orchard.Core.Common.Records;
using Orchard.Data; using Orchard.Data;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Common.Providers { namespace Orchard.Core.Common.Models {
public class BodyAspectHandler : ContentHandler { public class BodyAspectHandler : ContentHandler {
public BodyAspectHandler(IRepository<BodyRecord> bodyRepository) { public BodyAspectHandler(IRepository<BodyRecord> bodyRepository) {
Filters.Add(StorageFilter.For(bodyRepository)); Filters.Add(StorageFilter.For(bodyRepository));
} }
} }
} }

View File

@@ -1,4 +1,3 @@
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Records; using Orchard.Core.Common.Records;
using Orchard.Core.Common.ViewModels; using Orchard.Core.Common.ViewModels;
using Orchard.Data; using Orchard.Data;
@@ -9,7 +8,7 @@ using Orchard.ContentManagement.ViewModels;
using Orchard.Security; using Orchard.Security;
using Orchard.Services; using Orchard.Services;
namespace Orchard.Core.Common.Providers { namespace Orchard.Core.Common.Models {
public class CommonAspectHandler : ContentHandler { public class CommonAspectHandler : ContentHandler {
private readonly IClock _clock; private readonly IClock _clock;
private readonly IAuthenticationService _authenticationService; private readonly IAuthenticationService _authenticationService;
@@ -119,24 +118,24 @@ namespace Orchard.Core.Common.Providers {
// add handlers that will update records when aspect properties are set // add handlers that will update records when aspect properties are set
aspect.OwnerField.Setter(user => { aspect.OwnerField.Setter(user => {
if (user == null) { if (user == null) {
aspect.Record.OwnerId = 0; aspect.Record.OwnerId = 0;
} }
else { else {
aspect.Record.OwnerId = user.ContentItem.Id; aspect.Record.OwnerId = user.ContentItem.Id;
} }
return user; return user;
}); });
aspect.ContainerField.Setter(container => { aspect.ContainerField.Setter(container => {
if (container == null) { if (container == null) {
aspect.Record.Container = null; aspect.Record.Container = null;
} }
else { else {
aspect.Record.Container = container.ContentItem.Record; aspect.Record.Container = container.ContentItem.Record;
} }
return container; return container;
}); });
} }

View File

@@ -3,12 +3,15 @@ using JetBrains.Annotations;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Records;
using Orchard.Data;
namespace Orchard.Core.Common.Models { namespace Orchard.Core.Common.Models {
[UsedImplicitly] [UsedImplicitly]
public class RoutableAspectHandler : ContentHandler public class RoutableAspectHandler : ContentHandler {
{ public RoutableAspectHandler(IRepository<RoutableRecord> repository) {
public RoutableAspectHandler() { Filters.Add(StorageFilter.For(repository));
OnGetEditorViewModel<RoutableAspect>((context, routable) => { OnGetEditorViewModel<RoutableAspect>((context, routable) => {
var containerPathBuilder = new StringBuilder(); var containerPathBuilder = new StringBuilder();
var container = context.ContentItem.As<ICommonAspect>().Container; var container = context.ContentItem.As<ICommonAspect>().Container;

View File

@@ -1,11 +0,0 @@
using Orchard.Core.Common.Records;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Common.Providers {
public class RoutableAspectHandler : ContentHandler {
public RoutableAspectHandler(IRepository<RoutableRecord> repository) {
Filters.Add(StorageFilter.For(repository));
}
}
}

View File

@@ -71,12 +71,11 @@
<Compile Include="Common\Services\IRoutableService.cs" /> <Compile Include="Common\Services\IRoutableService.cs" />
<Compile Include="Common\Services\RoutableService.cs" /> <Compile Include="Common\Services\RoutableService.cs" />
<Compile Include="Common\Utilities\LazyField.cs" /> <Compile Include="Common\Utilities\LazyField.cs" />
<Compile Include="Common\Providers\CommonAspectHandler.cs" /> <Compile Include="Common\Models\CommonAspectHandler.cs" />
<Compile Include="Common\Models\CommonAspect.cs" /> <Compile Include="Common\Models\CommonAspect.cs" />
<Compile Include="Common\Providers\BodyAspectHandler.cs" /> <Compile Include="Common\Models\BodyAspectHandler.cs" />
<Compile Include="Common\Models\BodyAspect.cs" /> <Compile Include="Common\Models\BodyAspect.cs" />
<Compile Include="Common\Models\RoutableAspect.cs" /> <Compile Include="Common\Models\RoutableAspect.cs" />
<Compile Include="Common\Providers\RoutableAspectHandler.cs" />
<Compile Include="Common\Records\BodyRecord.cs" /> <Compile Include="Common\Records\BodyRecord.cs" />
<Compile Include="Common\Records\CommonRecord.cs" /> <Compile Include="Common\Records\CommonRecord.cs" />
<Compile Include="Common\Records\RoutableRecord.cs" /> <Compile Include="Common\Records\RoutableRecord.cs" />