Skip to content

Commit 2d0a1a0

Browse files
committed
Create sign provider collection and call registered providers on rendering a page of tree item view models.
Re-work tree controller constructors to provide registered providers as a collection.
1 parent a2cc6a0 commit 2d0a1a0

File tree

53 files changed

+718
-58
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+718
-58
lines changed

src/Umbraco.Cms.Api.Management/Controllers/DataType/Tree/AncestorsDataTypeTreeController.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Umbraco.Cms.Api.Management.Services.Signs;
46
using Umbraco.Cms.Api.Management.ViewModels.Tree;
57
using Umbraco.Cms.Core.Services;
68

@@ -9,11 +11,18 @@ namespace Umbraco.Cms.Api.Management.Controllers.DataType.Tree;
911
[ApiVersion("1.0")]
1012
public class AncestorsDataTypeTreeController : DataTypeTreeControllerBase
1113
{
14+
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
1215
public AncestorsDataTypeTreeController(IEntityService entityService, IDataTypeService dataTypeService)
1316
: base(entityService, dataTypeService)
1417
{
1518
}
1619

20+
[ActivatorUtilitiesConstructor]
21+
public AncestorsDataTypeTreeController(IEntityService entityService, SignProviderCollection signProviders, IDataTypeService dataTypeService)
22+
: base(entityService, signProviders, dataTypeService)
23+
{
24+
}
25+
1726
[HttpGet("ancestors")]
1827
[MapToApiVersion("1.0")]
1928
[ProducesResponseType(typeof(IEnumerable<DataTypeTreeItemResponseModel>), StatusCodes.Status200OK)]

src/Umbraco.Cms.Api.Management/Controllers/DataType/Tree/ChildrenDataTypeTreeController.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Umbraco.Cms.Core.Services;
55
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
66
using Umbraco.Cms.Api.Management.ViewModels.Tree;
7+
using Microsoft.Extensions.DependencyInjection;
8+
using Umbraco.Cms.Api.Management.Services.Signs;
79

810
namespace Umbraco.Cms.Api.Management.Controllers.DataType.Tree;
911

1012
[ApiVersion("1.0")]
1113
public class ChildrenDataTypeTreeController : DataTypeTreeControllerBase
1214
{
15+
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
1316
public ChildrenDataTypeTreeController(IEntityService entityService, IDataTypeService dataTypeService)
1417
: base(entityService, dataTypeService)
1518
{
1619
}
1720

21+
[ActivatorUtilitiesConstructor]
22+
public ChildrenDataTypeTreeController(IEntityService entityService, SignProviderCollection signProviders, IDataTypeService dataTypeService)
23+
: base(entityService, signProviders, dataTypeService)
24+
{
25+
}
26+
1827
[HttpGet("children")]
1928
[MapToApiVersion("1.0")]
2029
[ProducesResponseType(typeof(PagedViewModel<DataTypeTreeItemResponseModel>), StatusCodes.Status200OK)]

src/Umbraco.Cms.Api.Management/Controllers/DataType/Tree/DataTypeTreeControllerBase.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
using Microsoft.AspNetCore.Authorization;
1+
using Microsoft.AspNetCore.Authorization;
22
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.DependencyInjection;
34
using Umbraco.Cms.Api.Management.Controllers.Tree;
45
using Umbraco.Cms.Api.Management.Routing;
6+
using Umbraco.Cms.Api.Management.Services.Signs;
57
using Umbraco.Cms.Api.Management.ViewModels.Tree;
68
using Umbraco.Cms.Core;
9+
using Umbraco.Cms.Core.DependencyInjection;
710
using Umbraco.Cms.Core.Models;
811
using Umbraco.Cms.Core.Models.Entities;
912
using Umbraco.Cms.Core.Services;
@@ -19,8 +22,17 @@ public class DataTypeTreeControllerBase : FolderTreeControllerBase<DataTypeTreeI
1922
{
2023
private readonly IDataTypeService _dataTypeService;
2124

25+
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
2226
public DataTypeTreeControllerBase(IEntityService entityService, IDataTypeService dataTypeService)
23-
: base(entityService) =>
27+
: this(
28+
entityService,
29+
StaticServiceProvider.Instance.GetRequiredService<SignProviderCollection>(),
30+
dataTypeService)
31+
{
32+
}
33+
34+
public DataTypeTreeControllerBase(IEntityService entityService, SignProviderCollection signProviders, IDataTypeService dataTypeService)
35+
: base(entityService, signProviders) =>
2436
_dataTypeService = dataTypeService;
2537

2638
protected override UmbracoObjectTypes ItemObjectType => UmbracoObjectTypes.DataType;

src/Umbraco.Cms.Api.Management/Controllers/DataType/Tree/RootDataTypeTreeController.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Umbraco.Cms.Core.Services;
55
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
6-
using Umbraco.Cms.Api.Management.ViewModels.DataType.Item;
76
using Umbraco.Cms.Api.Management.ViewModels.Tree;
7+
using Microsoft.Extensions.DependencyInjection;
8+
using Umbraco.Cms.Api.Management.Services.Signs;
89

910
namespace Umbraco.Cms.Api.Management.Controllers.DataType.Tree;
1011

1112
[ApiVersion("1.0")]
1213
public class RootDataTypeTreeController : DataTypeTreeControllerBase
1314
{
15+
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
1416
public RootDataTypeTreeController(IEntityService entityService, IDataTypeService dataTypeService)
1517
: base(entityService, dataTypeService)
1618
{
1719
}
1820

21+
[ActivatorUtilitiesConstructor]
22+
public RootDataTypeTreeController(IEntityService entityService, SignProviderCollection signProviders, IDataTypeService dataTypeService)
23+
: base(entityService, signProviders, dataTypeService)
24+
{
25+
}
26+
1927
[HttpGet("root")]
2028
[MapToApiVersion("1.0")]
2129
[ProducesResponseType(typeof(PagedViewModel<DataTypeTreeItemResponseModel>), StatusCodes.Status200OK)]

src/Umbraco.Cms.Api.Management/Controllers/DataType/Tree/SiblingsDataTypeTreeController.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Umbraco.Cms.Api.Management.Services.Signs;
35
using Umbraco.Cms.Api.Management.ViewModels.Tree;
46
using Umbraco.Cms.Core.Services;
57

68
namespace Umbraco.Cms.Api.Management.Controllers.DataType.Tree;
79

810
public class SiblingsDataTypeTreeController : DataTypeTreeControllerBase
911
{
12+
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
1013
public SiblingsDataTypeTreeController(IEntityService entityService, IDataTypeService dataTypeService)
1114
: base(entityService, dataTypeService)
1215
{
1316
}
1417

18+
[ActivatorUtilitiesConstructor]
19+
public SiblingsDataTypeTreeController(IEntityService entityService, SignProviderCollection signProviders, IDataTypeService dataTypeService)
20+
: base(entityService, signProviders, dataTypeService)
21+
{
22+
}
23+
1524
[HttpGet("siblings")]
1625
[ProducesResponseType(typeof(IEnumerable<DataTypeTreeItemResponseModel>), StatusCodes.Status200OK)]
1726
public Task<ActionResult<IEnumerable<DataTypeTreeItemResponseModel>>> Siblings(CancellationToken cancellationToken, Guid target, int before, int after)

src/Umbraco.Cms.Api.Management/Controllers/Dictionary/Tree/AncestorsDictionaryTreeController.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Umbraco.Cms.Api.Management.Services.Signs;
46
using Umbraco.Cms.Api.Management.ViewModels.Tree;
57
using Umbraco.Cms.Core.Services;
68

@@ -9,11 +11,18 @@ namespace Umbraco.Cms.Api.Management.Controllers.Dictionary.Tree;
911
[ApiVersion("1.0")]
1012
public class AncestorsDictionaryTreeController : DictionaryTreeControllerBase
1113
{
14+
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
1215
public AncestorsDictionaryTreeController(IEntityService entityService, IDictionaryItemService dictionaryItemService)
1316
: base(entityService, dictionaryItemService)
1417
{
1518
}
1619

20+
[ActivatorUtilitiesConstructor]
21+
public AncestorsDictionaryTreeController(IEntityService entityService, SignProviderCollection signProviders, IDictionaryItemService dictionaryItemService)
22+
: base(entityService, signProviders, dictionaryItemService)
23+
{
24+
}
25+
1726
[HttpGet("ancestors")]
1827
[MapToApiVersion("1.0")]
1928
[ProducesResponseType(typeof(IEnumerable<NamedEntityTreeItemResponseModel>), StatusCodes.Status200OK)]

src/Umbraco.Cms.Api.Management/Controllers/Dictionary/Tree/ChildrenDictionaryTreeController.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Umbraco.Cms.Core.Models;
55
using Umbraco.Cms.Core.Services;
66
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
77
using Umbraco.Cms.Api.Management.ViewModels.Tree;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Umbraco.Cms.Api.Management.Services.Signs;
810

911
namespace Umbraco.Cms.Api.Management.Controllers.Dictionary.Tree;
1012

1113
[ApiVersion("1.0")]
1214
public class ChildrenDictionaryTreeController : DictionaryTreeControllerBase
1315
{
16+
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
1417
public ChildrenDictionaryTreeController(IEntityService entityService, IDictionaryItemService dictionaryItemService)
1518
: base(entityService, dictionaryItemService)
1619
{
1720
}
1821

22+
[ActivatorUtilitiesConstructor]
23+
public ChildrenDictionaryTreeController(IEntityService entityService, SignProviderCollection signProviders, IDictionaryItemService dictionaryItemService)
24+
: base(entityService, signProviders, dictionaryItemService)
25+
{
26+
}
27+
1928
[HttpGet("children")]
2029
[MapToApiVersion("1.0")]
2130
[ProducesResponseType(typeof(PagedViewModel<NamedEntityTreeItemResponseModel>), StatusCodes.Status200OK)]

src/Umbraco.Cms.Api.Management/Controllers/Dictionary/Tree/DictionaryTreeControllerBase.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
using Microsoft.AspNetCore.Authorization;
22
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.DependencyInjection;
34
using Umbraco.Cms.Api.Management.Controllers.Tree;
45
using Umbraco.Cms.Api.Management.Routing;
6+
using Umbraco.Cms.Api.Management.Services.Signs;
57
using Umbraco.Cms.Api.Management.ViewModels;
68
using Umbraco.Cms.Api.Management.ViewModels.Tree;
79
using Umbraco.Cms.Core;
10+
using Umbraco.Cms.Core.DependencyInjection;
811
using Umbraco.Cms.Core.Models;
912
using Umbraco.Cms.Core.Services;
1013
using Umbraco.Cms.Web.Common.Authorization;
@@ -18,8 +21,17 @@ namespace Umbraco.Cms.Api.Management.Controllers.Dictionary.Tree;
1821
// tree controller base. We'll keep it though, in the hope that we can mend EntityService.
1922
public class DictionaryTreeControllerBase : NamedEntityTreeControllerBase<NamedEntityTreeItemResponseModel>
2023
{
24+
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
2125
public DictionaryTreeControllerBase(IEntityService entityService, IDictionaryItemService dictionaryItemService)
22-
: base(entityService) =>
26+
: this(
27+
entityService,
28+
StaticServiceProvider.Instance.GetRequiredService<SignProviderCollection>(),
29+
dictionaryItemService)
30+
{
31+
}
32+
33+
public DictionaryTreeControllerBase(IEntityService entityService, SignProviderCollection signProviders, IDictionaryItemService dictionaryItemService)
34+
: base(entityService, signProviders) =>
2335
DictionaryItemService = dictionaryItemService;
2436

2537
// dictionary items do not currently have a known UmbracoObjectType, so we'll settle with Unknown for now

src/Umbraco.Cms.Api.Management/Controllers/Dictionary/Tree/RootDictionaryTreeController.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Umbraco.Cms.Core.Models;
55
using Umbraco.Cms.Core.Services;
66
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
77
using Umbraco.Cms.Api.Management.ViewModels.Tree;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Umbraco.Cms.Api.Management.Services.Signs;
810

911
namespace Umbraco.Cms.Api.Management.Controllers.Dictionary.Tree;
1012

@@ -16,6 +18,12 @@ public RootDictionaryTreeController(IEntityService entityService, IDictionaryIte
1618
{
1719
}
1820

21+
[ActivatorUtilitiesConstructor]
22+
public RootDictionaryTreeController(IEntityService entityService, SignProviderCollection signProviders, IDictionaryItemService dictionaryItemService)
23+
: base(entityService, signProviders, dictionaryItemService)
24+
{
25+
}
26+
1927
[HttpGet("root")]
2028
[MapToApiVersion("1.0")]
2129
[ProducesResponseType(typeof(PagedViewModel<NamedEntityTreeItemResponseModel>), StatusCodes.Status200OK)]

src/Umbraco.Cms.Api.Management/Controllers/Document/Tree/AncestorsDocumentTreeController.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.DependencyInjection;
45
using Umbraco.Cms.Api.Management.Factories;
56
using Umbraco.Cms.Api.Management.Services.Entities;
7+
using Umbraco.Cms.Api.Management.Services.Signs;
68
using Umbraco.Cms.Api.Management.ViewModels.Tree;
79
using Umbraco.Cms.Core.Cache;
810
using Umbraco.Cms.Core.Security;
@@ -13,6 +15,7 @@ namespace Umbraco.Cms.Api.Management.Controllers.Document.Tree;
1315
[ApiVersion("1.0")]
1416
public class AncestorsDocumentTreeController : DocumentTreeControllerBase
1517
{
18+
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
1619
public AncestorsDocumentTreeController(
1720
IEntityService entityService,
1821
IUserStartNodeEntitiesService userStartNodeEntitiesService,
@@ -32,6 +35,28 @@ public AncestorsDocumentTreeController(
3235
{
3336
}
3437

38+
[ActivatorUtilitiesConstructor]
39+
public AncestorsDocumentTreeController(
40+
IEntityService entityService,
41+
SignProviderCollection signProviders,
42+
IUserStartNodeEntitiesService userStartNodeEntitiesService,
43+
IDataTypeService dataTypeService,
44+
IPublicAccessService publicAccessService,
45+
AppCaches appCaches,
46+
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
47+
IDocumentPresentationFactory documentPresentationFactory)
48+
: base(
49+
entityService,
50+
signProviders,
51+
userStartNodeEntitiesService,
52+
dataTypeService,
53+
publicAccessService,
54+
appCaches,
55+
backofficeSecurityAccessor,
56+
documentPresentationFactory)
57+
{
58+
}
59+
3560
[HttpGet("ancestors")]
3661
[MapToApiVersion("1.0")]
3762
[ProducesResponseType(typeof(IEnumerable<DocumentTreeItemResponseModel>), StatusCodes.Status200OK)]

0 commit comments

Comments
 (0)