More NuCache/PublishedContent cleanup
This commit is contained in:
@@ -113,9 +113,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var originDraft = origin.DraftModel == null ? null : PublishedContent.UnwrapIPublishedContent(origin.DraftModel);
|
||||
var originPublished = origin.PublishedModel == null ? null : PublishedContent.UnwrapIPublishedContent(origin.PublishedModel);
|
||||
|
||||
DraftContent = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
DraftContent = originDraft == null ? null : new PublishedContent(this, originDraft.ContentData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
DraftModel = DraftContent?.CreateModel();
|
||||
PublishedContent = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
PublishedContent = originPublished == null ? null : new PublishedContent(this, originPublished.ContentData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
PublishedModel = PublishedContent?.CreateModel();
|
||||
|
||||
ChildContentIds = origin.ChildContentIds; // can be the *same* list
|
||||
@@ -164,8 +164,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
Node = this,
|
||||
ContentTypeId = ContentType.Id,
|
||||
|
||||
DraftData = draft?._contentData,
|
||||
PublishedData = published?._contentData
|
||||
DraftData = draft?.ContentData,
|
||||
PublishedData = published?.ContentData
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
|
||||
private readonly ContentNode _contentNode;
|
||||
// ReSharper disable once InconsistentNaming
|
||||
internal readonly ContentData _contentData; // internal for ContentNode cloning
|
||||
|
||||
private readonly string _urlSegment;
|
||||
|
||||
#region Constructors
|
||||
@@ -24,12 +21,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
public PublishedContent(ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
_contentNode = contentNode;
|
||||
_contentData = contentData;
|
||||
ContentData = contentData;
|
||||
_publishedSnapshotAccessor = publishedSnapshotAccessor;
|
||||
VariationContextAccessor = variationContextAccessor;
|
||||
|
||||
_urlSegment = _contentData.Name.ToUrlSegment();
|
||||
IsPreviewing = _contentData.Published == false;
|
||||
_urlSegment = ContentData.Name.ToUrlSegment();
|
||||
IsPreviewing = ContentData.Published == false;
|
||||
|
||||
var properties = new List<IPublishedProperty>();
|
||||
foreach (var propertyType in _contentNode.ContentType.PropertyTypes)
|
||||
@@ -70,7 +67,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_contentNode = contentNode;
|
||||
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
|
||||
VariationContextAccessor = origin.VariationContextAccessor;
|
||||
_contentData = origin._contentData;
|
||||
ContentData = origin.ContentData;
|
||||
|
||||
_urlSegment = origin._urlSegment;
|
||||
IsPreviewing = origin.IsPreviewing;
|
||||
@@ -87,7 +84,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
|
||||
VariationContextAccessor = origin.VariationContextAccessor;
|
||||
_contentNode = origin._contentNode;
|
||||
_contentData = origin._contentData;
|
||||
ContentData = origin.ContentData;
|
||||
|
||||
_urlSegment = origin._urlSegment;
|
||||
IsPreviewing = true;
|
||||
@@ -169,6 +166,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
#region PublishedContent
|
||||
|
||||
internal ContentData ContentData { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Id => _contentNode.Id;
|
||||
|
||||
@@ -178,11 +177,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
get
|
||||
{
|
||||
if (!ContentType.VariesByCulture())
|
||||
return _contentData.Name;
|
||||
return ContentData.Name;
|
||||
|
||||
var culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
|
||||
if (culture == "")
|
||||
return _contentData.Name;
|
||||
return ContentData.Name;
|
||||
|
||||
return Cultures.TryGetValue(culture, out var cultureInfos) ? cultureInfos.Name : null;
|
||||
}
|
||||
@@ -214,7 +213,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
public override string Path => _contentNode.Path;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int? TemplateId => _contentData.TemplateId;
|
||||
public override int? TemplateId => ContentData.TemplateId;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int CreatorId => _contentNode.CreatorId;
|
||||
@@ -226,13 +225,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
public override DateTime CreateDate => _contentNode.CreateDate;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int WriterId => _contentData.WriterId;
|
||||
public override int WriterId => ContentData.WriterId;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string WriterName => GetProfileNameById(_contentData.WriterId);
|
||||
public override string WriterName => GetProfileNameById(ContentData.WriterId);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DateTime UpdateDate => _contentData.VersionDate;
|
||||
public override DateTime UpdateDate => ContentData.VersionDate;
|
||||
|
||||
private IReadOnlyDictionary<string, PublishedCultureInfo> _cultureInfos;
|
||||
|
||||
@@ -262,9 +261,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
if (_cultureInfos != null) return _cultureInfos;
|
||||
|
||||
if (_contentData.CultureInfos == null)
|
||||
if (ContentData.CultureInfos == null)
|
||||
throw new Exception("oops: _contentDate.CultureInfos is null.");
|
||||
return _cultureInfos = _contentData.CultureInfos
|
||||
return _cultureInfos = ContentData.CultureInfos
|
||||
.ToDictionary(x => x.Key, x => new PublishedCultureInfo(x.Key, x.Value.Name, x.Value.Date), StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
@@ -276,7 +275,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
public override bool IsDraft(string culture = null)
|
||||
{
|
||||
// if this is the 'published' published content, nothing can be draft
|
||||
if (_contentData.Published)
|
||||
if (ContentData.Published)
|
||||
return false;
|
||||
|
||||
// not the 'published' published content, and does not vary = must be draft
|
||||
@@ -289,7 +288,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
// not the 'published' published content, and varies
|
||||
// = depends on the culture
|
||||
return _contentData.CultureInfos.TryGetValue(culture, out var cvar) && cvar.IsDraft;
|
||||
return ContentData.CultureInfos.TryGetValue(culture, out var cvar) && cvar.IsDraft;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -314,7 +313,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
// there is a 'published' published content, and varies
|
||||
// = depends on the culture
|
||||
return _contentNode.PublishedContent._contentData.CultureInfos.ContainsKey(culture);
|
||||
return _contentNode.PublishedContent.ContentData.CultureInfos.ContainsKey(culture);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user