Add UmbracoVirtualNodeByUdiRouteHandler (#6796)

* Add UmbracoVirtualNodeByUdiRouteHandler

* Parameter must be a GuidUdi
This commit is contained in:
Jeavon
2019-10-29 21:38:29 +01:00
committed by Sebastiaan Janssen
parent 8463f1db08
commit 4be1c3b4c4
2 changed files with 28 additions and 0 deletions

View File

@@ -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;
}
}
}

View File

@@ -256,6 +256,7 @@
<Compile Include="Models\TemplateQuery\OperatorFactory.cs" />
<Compile Include="UmbracoContextFactory.cs" />
<Compile Include="UmbracoContextReference.cs" />
<Compile Include="Mvc\UmbracoVirtualNodeByUdiRouteHandler.cs" />
<Compile Include="ViewDataExtensions.cs" />
<Compile Include="WebApi\Filters\AdminUsersAuthorizeAttribute.cs" />
<Compile Include="WebApi\Filters\OnlyLocalRequestsAttribute.cs" />