-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Decorators to mark Content Types as shared
- Loading branch information
1 parent
bed83e0
commit cd4f9ed
Showing
21 changed files
with
373 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
ToSic.Eav.Core/Data/ContentTypes/ContentType.Decorators.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace ToSic.Eav.Data | ||
{ | ||
public partial class ContentType: IHasDecorators<IContentType> | ||
{ | ||
public List<IDecorator<IContentType>> Decorators => | ||
_decorators ?? (_decorators = new List<IDecorator<IContentType>>()); | ||
private List<IDecorator<IContentType>> _decorators; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using ToSic.Eav.Documentation; | ||
|
||
namespace ToSic.Eav.Data | ||
{ | ||
public partial class ContentType | ||
{ | ||
|
||
#region Helpers just for creating ContentTypes which will be imported | ||
[PrivateApi] | ||
public void SetImportParameters(string scope, string staticName, string description, bool alwaysShareDef) | ||
{ | ||
Scope = scope; | ||
StaticName = staticName; | ||
Description = description; | ||
AlwaysShareConfiguration = alwaysShareDef; | ||
} | ||
|
||
// special values just needed for import / save | ||
// todo: try to place in a sub-object to un-clutter this ContentType object | ||
[PrivateApi] | ||
public bool OnSaveSortAttributes { get; set; } = false; | ||
|
||
[PrivateApi] | ||
public string OnSaveUseParentStaticName { get; set; } | ||
|
||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using ToSic.Eav.Metadata; | ||
|
||
namespace ToSic.Eav.Data | ||
{ | ||
public partial class ContentType | ||
{ | ||
|
||
#region Metadata | ||
|
||
/// <inheritdoc /> | ||
public ContentTypeMetadata Metadata => _metadata ?? (_metadata = new ContentTypeMetadata(StaticName, _metaSourceFinder)); | ||
|
||
private ContentTypeMetadata _metadata; | ||
private readonly Func<IHasMetadataSource> _metaSourceFinder; | ||
|
||
IMetadataOf IHasMetadata.Metadata => Metadata; | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace ToSic.Eav.Data | ||
{ | ||
public partial class ContentType | ||
{ | ||
|
||
#region Sharing Content Types | ||
///// <inheritdoc /> | ||
//public int? ParentId { get; internal set; } | ||
///// <inheritdoc /> | ||
//public int ParentAppId { get; } | ||
///// <inheritdoc /> | ||
//public int ParentZoneId { get; } | ||
/// <inheritdoc /> | ||
public bool AlwaysShareConfiguration { get; private set; } | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using ToSic.Eav.Data.Shared; | ||
|
||
namespace ToSic.Eav.Data | ||
{ | ||
public static class ContentTypeExtensions | ||
{ | ||
public static bool HasAncestor(this IContentType contentType) | ||
{ | ||
var anc = contentType.GetDecorator<IAncestor>(); | ||
return anc != null && anc.Id != 0; | ||
} | ||
|
||
public static bool HasPresetAncestor(this IContentType contentType) | ||
{ | ||
var anc = contentType.GetDecorator<IAncestor>(); | ||
return anc != null && anc.Id == Constants.PresetContentTypeFakeParent; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
ToSic.Eav.Core/Data/ContentTypes/ContentTypeWrapper.Equality.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
|
||
namespace ToSic.Eav.Data | ||
{ | ||
public partial class ContentTypeWrapper : IEquatable<ContentTypeWrapper> | ||
{ | ||
public bool Equals(ContentTypeWrapper other) | ||
{ | ||
if (ReferenceEquals(null, other?.GetContents())) return false; | ||
if (ReferenceEquals(this, other)) return true; | ||
return Equals(GetContents(), other.GetContents()); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
if (obj.GetType() != this.GetType()) return false; | ||
return Equals((ContentTypeWrapper)obj); | ||
} | ||
|
||
public override int GetHashCode() => (GetContents() != null ? GetContents().GetHashCode() : 0); | ||
} | ||
} |
Oops, something went wrong.