From 4be1c3b4c4f26bd0925a3164d32f554b679045da Mon Sep 17 00:00:00 2001 From: Jeavon Date: Tue, 29 Oct 2019 21:38:29 +0100 Subject: [PATCH] Add UmbracoVirtualNodeByUdiRouteHandler (#6796) * Add UmbracoVirtualNodeByUdiRouteHandler * Parameter must be a GuidUdi --- .../UmbracoVirtualNodeByUdiRouteHandler.cs | 27 +++++++++++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 1 + 2 files changed, 28 insertions(+) create mode 100644 src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs diff --git a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs new file mode 100644 index 000000000000..a1ee6c732a67 --- /dev/null +++ b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs @@ -0,0 +1,27 @@ +using System.Web.Routing; +using Umbraco.Core; +using Umbraco.Core.Models.PublishedContent; + +namespace Umbraco.Web.Mvc +{ + public class UmbracoVirtualNodeByUdiRouteHandler : UmbracoVirtualNodeRouteHandler + { + private readonly Udi _realNodeUdi; + + public UmbracoVirtualNodeByUdiRouteHandler(GuidUdi realNodeUdi) + { + _realNodeUdi = realNodeUdi; + } + + protected sealed override IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext) + { + var byId = umbracoContext.Content.GetById(_realNodeUdi); + return byId == null ? null : FindContent(requestContext, umbracoContext, byId); + } + + protected virtual IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext, IPublishedContent baseContent) + { + return baseContent; + } + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 41c2d93489bc..56feaf52e74c 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -256,6 +256,7 @@ +