-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UmbracoVirtualNodeByUdiRouteHandler (#6796)
* Add UmbracoVirtualNodeByUdiRouteHandler * Parameter must be a GuidUdi
- Loading branch information
1 parent
8463f1d
commit 4be1c3b
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters