Skip to content

Commit

Permalink
Add UmbracoVirtualNodeByUdiRouteHandler (#6796)
Browse files Browse the repository at this point in the history
* Add UmbracoVirtualNodeByUdiRouteHandler

* Parameter must be a GuidUdi
  • Loading branch information
Jeavon authored and nul800sebastiaan committed Oct 29, 2019
1 parent 8463f1d commit 4be1c3b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
1 change: 1 addition & 0 deletions src/Umbraco.Web/Umbraco.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down

0 comments on commit 4be1c3b

Please sign in to comment.