From b8bfdf14418daec90aab63633d3bb9ffb57ab04c Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Sat, 1 Feb 2020 18:19:50 +0100 Subject: [PATCH] Restored type check for NuCache status controller. Added service located extension method for retrieving creator and writer name. --- .../Umbraco.Infrastructure.PublishedCache.csproj | 3 +++ .../Editors/NuCacheStatusController.cs | 10 ++++------ src/Umbraco.Web/PublishedContentExtensions.cs | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj b/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj index d4c30668c5..f818df2d41 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj +++ b/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj @@ -15,6 +15,9 @@ + + <_Parameter1>Umbraco.Web + <_Parameter1>Umbraco.Tests diff --git a/src/Umbraco.Web/Editors/NuCacheStatusController.cs b/src/Umbraco.Web/Editors/NuCacheStatusController.cs index 0f50682e77..3494b7ba96 100644 --- a/src/Umbraco.Web/Editors/NuCacheStatusController.cs +++ b/src/Umbraco.Web/Editors/NuCacheStatusController.cs @@ -21,12 +21,10 @@ namespace Umbraco.Web.Editors { get { - // TODO: do we need this? - //var svc = _publishedSnapshotService as PublishedSnapshotService; - //if (svc == null) - // throw new NotSupportedException("Not running NuCache."); - // return svc; - return _publishedSnapshotService; + var svc = _publishedSnapshotService as PublishedSnapshotService; + if (svc == null) + throw new NotSupportedException("Not running NuCache."); + return svc; } } diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index fe42d5a165..73696bc8d4 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -28,6 +28,7 @@ namespace Umbraco.Web private static UmbracoContext UmbracoContext => Current.UmbracoContext; private static ISiteDomainHelper SiteDomainHelper => Current.Factory.GetInstance(); private static IVariationContextAccessor VariationContextAccessor => Current.VariationContextAccessor; + private static IUserService UserService => Current.Services.UserService; #region IsComposedOf @@ -795,6 +796,20 @@ namespace Umbraco.Web #endregion + #region Writer and creator + + public static string CreatorName(this IPublishedContent content) + { + return content.GetCreatorName(UserService); + } + + public static string WriterName(this IPublishedContent content) + { + return content.GetWriterName(UserService); + } + + #endregion + #region Url ///