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