Merge remote-tracking branch 'origin/temp8' into temp8-injection-ihttpcontextaccessor-instead-of-controller
# Conflicts: # src/Umbraco.Tests/Web/Mvc/RenderIndexActionSelectorAttributeTests.cs # src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs # src/Umbraco.Web/Editors/Filters/UserGroupAuthorizationAttribute.cs # src/Umbraco.Web/Mvc/EnsurePublishedContentRequestAttribute.cs # src/Umbraco.Web/Mvc/RedirectToUmbracoPageResult.cs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace Umbraco.Web.Trees
|
||||
public Tree(int sortOrder, string applicationAlias, string group, string alias, string title, TreeUse use, Type treeControllerType, bool isSingleNodeTree)
|
||||
{
|
||||
SortOrder = sortOrder;
|
||||
SectionAlias = applicationAlias;
|
||||
SectionAlias = applicationAlias ?? throw new ArgumentNullException(nameof(applicationAlias));
|
||||
TreeGroup = group;
|
||||
TreeAlias = alias;
|
||||
TreeAlias = alias ?? throw new ArgumentNullException(nameof(alias));
|
||||
TreeTitle = title;
|
||||
TreeUse = use;
|
||||
TreeControllerType = treeControllerType;
|
||||
TreeControllerType = treeControllerType ?? throw new ArgumentNullException(nameof(treeControllerType));
|
||||
IsSingleNodeTree = isSingleNodeTree;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,20 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
public void RegisterWith(IRegister register) => register.Register(CreateCollection, Lifetime.Singleton);
|
||||
|
||||
/// <summary>
|
||||
/// Registers a custom tree definition
|
||||
/// </summary>
|
||||
/// <param name="treeDefinition"></param>
|
||||
/// <remarks>
|
||||
/// This is useful if a developer wishes to have a single tree controller for different tree aliases. In this case the tree controller
|
||||
/// cannot be decorated with the TreeAttribute (since then it will be auto-registered).
|
||||
/// </remarks>
|
||||
public void AddTree(Tree treeDefinition)
|
||||
{
|
||||
if (treeDefinition == null) throw new ArgumentNullException(nameof(treeDefinition));
|
||||
_trees.Add(treeDefinition);
|
||||
}
|
||||
|
||||
public void AddTreeController<TController>()
|
||||
where TController : TreeControllerBase
|
||||
=> AddTreeController(typeof(TController));
|
||||
@@ -25,7 +39,7 @@ namespace Umbraco.Web.Trees
|
||||
if (!typeof(TreeControllerBase).IsAssignableFrom(controllerType))
|
||||
throw new ArgumentException($"Type {controllerType} does not inherit from {typeof(TreeControllerBase).FullName}.");
|
||||
|
||||
// no all TreeControllerBase are meant to be used here,
|
||||
// not all TreeControllerBase are meant to be used here,
|
||||
// ignore those that don't have the attribute
|
||||
|
||||
var attribute = controllerType.GetCustomAttribute<TreeAttribute>(false);
|
||||
|
||||
Reference in New Issue
Block a user