U4-7925 Add dependency injection to Umbraco.Web.Trees.TreeController*
This commit is contained in:
@@ -18,25 +18,23 @@ namespace Umbraco.Web.Trees
|
||||
/// </summary>
|
||||
public abstract class TreeController : TreeControllerBase
|
||||
{
|
||||
private readonly TreeAttribute _attribute;
|
||||
private TreeAttribute _attribute;
|
||||
|
||||
protected TreeController()
|
||||
{
|
||||
//Locate the tree attribute
|
||||
var treeAttributes = GetType()
|
||||
.GetCustomAttributes(typeof(TreeAttribute), false)
|
||||
.OfType<TreeAttribute>()
|
||||
.ToArray();
|
||||
|
||||
if (treeAttributes.Any() == false)
|
||||
{
|
||||
throw new InvalidOperationException("The Tree controller is missing the " + typeof(TreeAttribute).FullName + " attribute");
|
||||
}
|
||||
|
||||
//assign the properties of this object to those of the metadata attribute
|
||||
_attribute = treeAttributes.First();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
protected TreeController(UmbracoContext umbracoContext) : base(umbracoContext)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
protected TreeController(UmbracoContext umbracoContext, UmbracoHelper umbracoHelper) : base(umbracoContext, umbracoHelper)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name to display on the root node
|
||||
/// </summary>
|
||||
@@ -68,5 +66,21 @@ namespace Umbraco.Web.Trees
|
||||
get { return _attribute.Alias; }
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
//Locate the tree attribute
|
||||
var treeAttributes = GetType()
|
||||
.GetCustomAttributes(typeof(TreeAttribute), false)
|
||||
.OfType<TreeAttribute>()
|
||||
.ToArray();
|
||||
|
||||
if (treeAttributes.Any() == false)
|
||||
{
|
||||
throw new InvalidOperationException("The Tree controller is missing the " + typeof(TreeAttribute).FullName + " attribute");
|
||||
}
|
||||
|
||||
//assign the properties of this object to those of the metadata attribute
|
||||
_attribute = treeAttributes.First();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,18 @@ namespace Umbraco.Web.Trees
|
||||
[AngularJsonOnlyConfiguration]
|
||||
public abstract class TreeControllerBase : UmbracoAuthorizedApiController
|
||||
{
|
||||
protected TreeControllerBase()
|
||||
{
|
||||
}
|
||||
|
||||
protected TreeControllerBase(UmbracoContext umbracoContext) : base(umbracoContext)
|
||||
{
|
||||
}
|
||||
|
||||
protected TreeControllerBase(UmbracoContext umbracoContext, UmbracoHelper umbracoHelper) : base(umbracoContext, umbracoHelper)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method called to render the contents of the tree structure
|
||||
/// </summary>
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Umbraco.Web.WebApi
|
||||
/// The base class for auto-routed API controllers for Umbraco
|
||||
/// </summary>
|
||||
public abstract class UmbracoApiController : UmbracoApiControllerBase
|
||||
{
|
||||
{
|
||||
protected UmbracoApiController()
|
||||
{
|
||||
}
|
||||
@@ -20,5 +20,9 @@ namespace Umbraco.Web.WebApi
|
||||
protected UmbracoApiController(UmbracoContext umbracoContext) : base(umbracoContext)
|
||||
{
|
||||
}
|
||||
|
||||
protected UmbracoApiController(UmbracoContext umbracoContext, UmbracoHelper umbracoHelper) : base(umbracoContext, umbracoHelper)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,16 @@ namespace Umbraco.Web.WebApi
|
||||
{
|
||||
protected UmbracoAuthorizedApiController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected UmbracoAuthorizedApiController(UmbracoContext umbracoContext)
|
||||
: base(umbracoContext)
|
||||
protected UmbracoAuthorizedApiController(UmbracoContext umbracoContext) : base(umbracoContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected UmbracoAuthorizedApiController(UmbracoContext umbracoContext, UmbracoHelper umbracoHelper) : base(umbracoContext, umbracoHelper)
|
||||
{
|
||||
}
|
||||
|
||||
private bool _userisValidated = false;
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user