2018-06-29 19:52:40 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Diagnostics;
|
2021-02-18 11:06:02 +01:00
|
|
|
|
using Umbraco.Extensions;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
|
namespace Umbraco.Cms.Core.Models.PublishedContent
|
2018-06-29 19:52:40 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Provide an abstract base class for <c>IPublishedContent</c> implementations.
|
|
|
|
|
|
/// </summary>
|
2020-10-05 20:48:38 +02:00
|
|
|
|
/// <remarks>This base class does which (a) consistently resolves and caches the URL, (b) provides an implementation
|
2018-06-29 19:52:40 +02:00
|
|
|
|
/// for this[alias], and (c) provides basic content set management.</remarks>
|
2019-06-21 15:46:16 +10:00
|
|
|
|
[DebuggerDisplay("Content Id: {Id}")]
|
2018-06-29 19:52:40 +02:00
|
|
|
|
public abstract class PublishedContentBase : IPublishedContent
|
|
|
|
|
|
{
|
2019-12-19 10:43:00 +01:00
|
|
|
|
private readonly IVariationContextAccessor _variationContextAccessor;
|
|
|
|
|
|
|
|
|
|
|
|
protected PublishedContentBase(IVariationContextAccessor variationContextAccessor)
|
|
|
|
|
|
{
|
|
|
|
|
|
_variationContextAccessor = variationContextAccessor;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-29 19:52:40 +02:00
|
|
|
|
#region ContentType
|
|
|
|
|
|
|
2019-04-15 13:04:14 +02:00
|
|
|
|
public abstract IPublishedContentType ContentType { get; }
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2018-04-28 16:34:43 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2018-06-29 19:52:40 +02:00
|
|
|
|
#region PublishedElement
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract Guid Key { get; }
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region PublishedContent
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract int Id { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2022-01-21 11:43:58 +01:00
|
|
|
|
public virtual string? Name => this.Name(_variationContextAccessor);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2022-01-21 11:43:58 +01:00
|
|
|
|
public virtual string? UrlSegment => this.UrlSegment(_variationContextAccessor);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract int SortOrder { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract int Level { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract string Path { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2018-11-15 07:23:09 +00:00
|
|
|
|
public abstract int? TemplateId { get; }
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract int CreatorId { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract DateTime CreateDate { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract int WriterId { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract DateTime UpdateDate { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2019-06-06 16:54:00 +02:00
|
|
|
|
public abstract IReadOnlyDictionary<string, PublishedCultureInfo> Cultures { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public abstract PublishedItemType ItemType { get; }
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2022-01-21 11:43:58 +01:00
|
|
|
|
public abstract bool IsDraft(string? culture = null);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2019-01-24 15:22:20 +01:00
|
|
|
|
/// <inheritdoc />
|
2022-01-21 11:43:58 +01:00
|
|
|
|
public abstract bool IsPublished(string? culture = null);
|
2019-01-23 07:54:45 +01:00
|
|
|
|
|
2018-06-29 19:52:40 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Tree
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2019-06-06 16:54:00 +02:00
|
|
|
|
public abstract IPublishedContent Parent { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2019-12-19 10:43:00 +01:00
|
|
|
|
public virtual IEnumerable<IPublishedContent> Children => this.Children(_variationContextAccessor);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2019-06-06 16:54:00 +02:00
|
|
|
|
public abstract IEnumerable<IPublishedContent> ChildrenForAllCultures { get; }
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc cref="IPublishedElement.Properties"/>
|
|
|
|
|
|
public abstract IEnumerable<IPublishedProperty> Properties { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc cref="IPublishedElement.GetProperty(string)"/>
|
|
|
|
|
|
public abstract IPublishedProperty GetProperty(string alias);
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|