U4-7925 Add dependency injection to Umbraco.Web.Trees.TreeController*
This commit is contained in:
@@ -18,25 +18,23 @@ namespace Umbraco.Web.Trees
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class TreeController : TreeControllerBase
|
public abstract class TreeController : TreeControllerBase
|
||||||
{
|
{
|
||||||
private readonly TreeAttribute _attribute;
|
private TreeAttribute _attribute;
|
||||||
|
|
||||||
protected TreeController()
|
protected TreeController()
|
||||||
{
|
{
|
||||||
//Locate the tree attribute
|
Initialize();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected TreeController(UmbracoContext umbracoContext) : base(umbracoContext)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TreeController(UmbracoContext umbracoContext, UmbracoHelper umbracoHelper) : base(umbracoContext, umbracoHelper)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name to display on the root node
|
/// The name to display on the root node
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -68,5 +66,21 @@ namespace Umbraco.Web.Trees
|
|||||||
get { return _attribute.Alias; }
|
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]
|
[AngularJsonOnlyConfiguration]
|
||||||
public abstract class TreeControllerBase : UmbracoAuthorizedApiController
|
public abstract class TreeControllerBase : UmbracoAuthorizedApiController
|
||||||
{
|
{
|
||||||
|
protected TreeControllerBase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TreeControllerBase(UmbracoContext umbracoContext) : base(umbracoContext)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TreeControllerBase(UmbracoContext umbracoContext, UmbracoHelper umbracoHelper) : base(umbracoContext, umbracoHelper)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The method called to render the contents of the tree structure
|
/// The method called to render the contents of the tree structure
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Umbraco.Web.WebApi
|
|||||||
/// The base class for auto-routed API controllers for Umbraco
|
/// The base class for auto-routed API controllers for Umbraco
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class UmbracoApiController : UmbracoApiControllerBase
|
public abstract class UmbracoApiController : UmbracoApiControllerBase
|
||||||
{
|
{
|
||||||
protected UmbracoApiController()
|
protected UmbracoApiController()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -20,5 +20,9 @@ namespace Umbraco.Web.WebApi
|
|||||||
protected UmbracoApiController(UmbracoContext umbracoContext) : base(umbracoContext)
|
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()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UmbracoAuthorizedApiController(UmbracoContext umbracoContext)
|
protected UmbracoAuthorizedApiController(UmbracoContext umbracoContext) : base(umbracoContext)
|
||||||
: base(umbracoContext)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected UmbracoAuthorizedApiController(UmbracoContext umbracoContext, UmbracoHelper umbracoHelper) : base(umbracoContext, umbracoHelper)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private bool _userisValidated = false;
|
private bool _userisValidated = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user