#19380: Removing needless content type definition fetching from CommonPartHandler

Work Item: 19380

--HG--
branch : 1.x
This commit is contained in:
Zoltán Lehóczky
2013-05-15 16:59:31 +02:00
parent 6ca76c68bb
commit 3fef593881

View File

@@ -9,6 +9,7 @@ using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Security;
using Orchard.Services;
using Orchard.ContentManagement.MetaData.Models;
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
@@ -63,14 +64,12 @@ namespace Orchard.Core.Common.Handlers {
public Localizer T { get; set; }
protected override void Activating(ActivatingContentContext context) {
if (ContentTypeWithACommonPart(context.ContentType))
if (ContentTypeWithACommonPart(context.Definition))
context.Builder.Weld<ContentPart<CommonPartVersionRecord>>();
}
protected bool ContentTypeWithACommonPart(string typeName) {
protected bool ContentTypeWithACommonPart(ContentTypeDefinition contentTypeDefinition) {
//Note: What about content type handlers which activate "CommonPart" in code?
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName);
if (contentTypeDefinition != null)
return contentTypeDefinition.Parts.Any(part => part.PartDefinition.Name == "CommonPart");