Replace surface with area name if surface controller has one

This commit is contained in:
Mole
2021-06-30 14:36:08 +02:00
parent 73f8ed7e12
commit 0835423e68
3 changed files with 56 additions and 3 deletions

View File

@@ -122,5 +122,27 @@ namespace Umbraco.Extensions
true,
constraints);
}
public static void MapUmbracoSurfaceRoute(
this IEndpointRouteBuilder endpoints,
Type controllerType,
string rootSegment,
string areaName,
string defaultAction = "Index",
bool includeControllerNameInRoute = true,
object constraints = null)
{
// If there is an area name it's a plugin controller, and we should use the area name instead of surface
string prefixPathSegment = areaName.IsNullOrWhiteSpace() ? "Surface" : areaName;
endpoints.MapUmbracoRoute(
controllerType,
rootSegment,
areaName,
prefixPathSegment,
defaultAction,
includeControllerNameInRoute,
constraints);
}
}
}