mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 02:44:52 +08:00
Removing ContentType
--HG-- branch : theming
This commit is contained in:
@@ -41,7 +41,7 @@ namespace Orchard.Core.Tests.Body {
|
||||
public void BodyCanHandleLongText() {
|
||||
var contentManager = _container.Resolve<IContentManager>();
|
||||
|
||||
contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
|
||||
contentManager.Create<Thing>(ThingDriver.ContentTypeName, t => {
|
||||
t.As<BodyPart>().Record = new BodyPartRecord();
|
||||
t.Text = new String('x', 10000);
|
||||
});
|
||||
@@ -69,10 +69,10 @@ namespace Orchard.Core.Tests.Body {
|
||||
[UsedImplicitly]
|
||||
public class ThingHandler : ContentHandler {
|
||||
public ThingHandler() {
|
||||
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentType.Name));
|
||||
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(ThingDriver.ContentType.Name));
|
||||
Filters.Add(new ActivatingFilter<CommonPart>(ThingDriver.ContentType.Name));
|
||||
Filters.Add(new ActivatingFilter<BodyPart>(ThingDriver.ContentType.Name));
|
||||
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentTypeName));
|
||||
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(ThingDriver.ContentTypeName));
|
||||
Filters.Add(new ActivatingFilter<CommonPart>(ThingDriver.ContentTypeName));
|
||||
Filters.Add(new ActivatingFilter<BodyPart>(ThingDriver.ContentTypeName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,10 +87,7 @@ namespace Orchard.Core.Tests.Body {
|
||||
}
|
||||
|
||||
public class ThingDriver : ContentPartDriver<Thing> {
|
||||
public readonly static ContentType ContentType = new ContentType {
|
||||
Name = "thing",
|
||||
DisplayName = "Thing"
|
||||
};
|
||||
public static readonly string ContentTypeName = "thing";
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -165,7 +165,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
|
||||
[Test]
|
||||
public void GetContentTypesShouldReturnAllTypes() {
|
||||
var types = _manager.GetContentTypes();
|
||||
var types = _manager.GetContentTypeDefinitions();
|
||||
Assert.That(types.Count(), Is.EqualTo(4));
|
||||
Assert.That(types, Has.Some.With.Property("Name").EqualTo("alpha"));
|
||||
Assert.That(types, Has.Some.With.Property("Name").EqualTo("beta"));
|
||||
|
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
|
||||
namespace Orchard.Tests.ContentManagement.Models {
|
||||
@@ -8,9 +6,7 @@ namespace Orchard.Tests.ContentManagement.Models {
|
||||
public AlphaHandler() {
|
||||
OnGetDisplayShape<Alpha>((ctx, part) => ctx.AddDisplay(new TemplateViewModel(part) { Position = "3" }));
|
||||
}
|
||||
public override IEnumerable<ContentType> GetContentTypes() {
|
||||
return new[] { new ContentType { Name = "alpha" } };
|
||||
}
|
||||
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
if (context.ContentType == "alpha") {
|
||||
context.Builder.Weld<Alpha>();
|
||||
|
@@ -1,16 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
|
||||
namespace Orchard.Tests.ContentManagement.Models {
|
||||
public class BetaHandler : ContentHandler {
|
||||
public override System.Collections.Generic.IEnumerable<Orchard.ContentManagement.ContentType> GetContentTypes() {
|
||||
return new[] { new ContentType { Name = "beta" } };
|
||||
}
|
||||
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
if (context.ContentType == "beta") {
|
||||
context.Builder.Weld<Beta>();
|
||||
|
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Orchard.Data;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Tests.ContentManagement.Records;
|
||||
@@ -13,9 +9,6 @@ namespace Orchard.Tests.ContentManagement.Models {
|
||||
|
||||
|
||||
public class DeltaHandler : ContentHandler {
|
||||
public override System.Collections.Generic.IEnumerable<Orchard.ContentManagement.ContentType> GetContentTypes() {
|
||||
return new[] { new ContentType { Name = "delta" } };
|
||||
}
|
||||
|
||||
public DeltaHandler(IRepository<DeltaRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<Delta>(x => x == "delta"));
|
||||
|
@@ -9,10 +9,6 @@ namespace Orchard.Tests.ContentManagement.Models {
|
||||
|
||||
|
||||
public class GammaHandler : ContentHandler {
|
||||
public override System.Collections.Generic.IEnumerable<ContentType> GetContentTypes() {
|
||||
return new[] { new ContentType { Name = "gamma" } };
|
||||
}
|
||||
|
||||
public GammaHandler(IRepository<GammaRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<Gamma>(x => x == "gamma"));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
|
@@ -3,7 +3,6 @@ using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Core.Settings.Models {
|
||||
public sealed class SiteSettingsPart : ContentPart<SiteSettingsPartRecord>, ISite {
|
||||
public static readonly ContentType ContentType = new ContentType { Name = "Site", DisplayName = "Site Settings" };
|
||||
|
||||
public string PageTitleSeparator {
|
||||
get { return Record.PageTitleSeparator; }
|
||||
|
@@ -1,6 +0,0 @@
|
||||
namespace Orchard.ContentManagement {
|
||||
public class ContentType {
|
||||
public string Name { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ using Autofac;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.Indexing;
|
||||
@@ -43,10 +44,8 @@ namespace Orchard.ContentManagement {
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<ContentType> GetContentTypes() {
|
||||
return Handlers.Aggregate(
|
||||
Enumerable.Empty<ContentType>(),
|
||||
(types, handler) => types.Concat(handler.GetContentTypes()));
|
||||
public IEnumerable<ContentTypeDefinition> GetContentTypeDefinitions() {
|
||||
return _contentDefinitionManager.ListTypeDefinitions();
|
||||
}
|
||||
|
||||
public virtual ContentItem New(string contentType) {
|
||||
|
@@ -181,10 +181,6 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerable<ContentType> GetContentTypes() {
|
||||
return Enumerable.Empty<ContentType>();
|
||||
}
|
||||
|
||||
void IContentHandler.Activating(ActivatingContentContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentActivatingFilter>())
|
||||
filter.Activating(context);
|
||||
|
@@ -1,12 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class ContentHandlerBase : IContentHandler {
|
||||
public virtual IEnumerable<ContentType> GetContentTypes() {
|
||||
return Enumerable.Empty<ContentType>();
|
||||
}
|
||||
|
||||
public virtual void Activating(ActivatingContentContext context) {}
|
||||
public virtual void Activated(ActivatedContentContext context) {}
|
||||
public virtual void Initializing(InitializingContentContext context) {}
|
||||
|
@@ -1,9 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public interface IContentHandler : IEvents {
|
||||
IEnumerable<ContentType> GetContentTypes();
|
||||
|
||||
void Activating(ActivatingContentContext context);
|
||||
void Activated(ActivatedContentContext context);
|
||||
void Initializing(InitializingContentContext context);
|
||||
|
@@ -1,10 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.Indexing;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement {
|
||||
public interface IContentManager : IDependency {
|
||||
IEnumerable<ContentType> GetContentTypes();
|
||||
IEnumerable<ContentTypeDefinition> GetContentTypeDefinitions();
|
||||
|
||||
ContentItem New(string contentType);
|
||||
|
||||
|
Reference in New Issue
Block a user