Skip to content

Commit

Permalink
Replace AdminRouteAttribute with AdminAttribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Mar 18, 2024
1 parent b7259b2 commit 09ff84a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
4 changes: 0 additions & 4 deletions Lombiq.HelpfulLibraries.OrchardCore/Docs/Mvc.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ If you also use our [UI Testing Toolbox](https://github.com/Lombiq/UI-Testing-To
## `WidgetFilterBase<T>`

A base class for creating filters that insert a content as widget in a specified zone with permission check.

## `[AdminRoute]`

`[AdminRoute("My/Path/{id}")]` can be applied to any MVC action method. It work the same way as if you used [Route("Admin/My/Path/{id}")] except the admin prefix is no longer hard coded. This functionality is enabled by registering its mapper as a DI service using the `AdminRouteAttributeRouteMapper.AddToServices(services)` static method.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lombiq.HelpfulLibraries.OrchardCore.Mvc;

[Obsolete("Use the [Admin(route)] attribute instead.")]
[AttributeUsage(AttributeTargets.Method)]
public sealed class AdminRouteAttribute : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Extensions.Options;
using OrchardCore.Admin;
using OrchardCore.Mvc.Routing;
using System;
using System.Reflection;

namespace Lombiq.HelpfulLibraries.OrchardCore.Mvc;
Expand All @@ -25,6 +26,7 @@ namespace Lombiq.HelpfulLibraries.OrchardCore.Mvc;
/// It can be added to the DI service collection using the <see cref="AddToServices"/> static method.
/// </para>
/// </remarks>
[Obsolete("Use the [Admin(route)] attribute instead of [AdminRoute(route)].")]
public class AdminRouteAttributeRouteMapper : IAreaControllerRouteMapper
{
private readonly string _adminUrlPrefix;
Expand Down
2 changes: 1 addition & 1 deletion Lombiq.HelpfulLibraries.OrchardCore/Mvc/TypedRoute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public string ToString(HttpContext httpContext)
public override string ToString()
{
var routeTemplate = _action.GetCustomAttribute<RouteAttribute>()?.Template ??
_action.GetCustomAttribute<AdminRouteAttribute>()?.Template;
_action.GetCustomAttribute<AdminAttribute>()?.Template;
var (route, arguments) = routeTemplate != null && !string.IsNullOrWhiteSpace(routeTemplate)
? GetRouteFromTemplate(routeTemplate, _arguments)
: ($"{_area}/{_controller.ControllerName()}/{_action.GetCustomAttribute<ActionNameAttribute>()?.Name ?? _action.Name}", _arguments);
Expand Down

0 comments on commit 09ff84a

Please sign in to comment.