Skip to content

Commit 04df265

Browse files
committed
Trees: Restore backward compatibility for file system based tree controllers (closes #20602) (#20608)
* Restore backward compatibility for file system based tree controllers. * Aligned obsoletion messages.
1 parent 1bf53f3 commit 04df265

16 files changed

+225
-210
lines changed

src/Umbraco.Cms.Api.Management/Controllers/PartialView/Tree/AncestorsPartialViewTreeController.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.DependencyInjection;
55
using Umbraco.Cms.Api.Management.Services.FileSystem;
66
using Umbraco.Cms.Api.Management.ViewModels.Tree;
7-
using Umbraco.Cms.Core.DependencyInjection;
87
using Umbraco.Cms.Core.IO;
9-
using Umbraco.Cms.Core.Services;
108

119
namespace Umbraco.Cms.Api.Management.Controllers.PartialView.Tree;
1210

1311
[ApiVersion("1.0")]
1412
public class AncestorsPartialViewTreeController : PartialViewTreeControllerBase
1513
{
16-
private readonly IPartialViewTreeService _partialViewTreeService;
17-
1814
// TODO Remove the static service provider, and replace with base when the other constructors are obsoleted.
15+
[ActivatorUtilitiesConstructor]
1916
public AncestorsPartialViewTreeController(IPartialViewTreeService partialViewTreeService)
20-
: this(partialViewTreeService, StaticServiceProvider.Instance.GetRequiredService<FileSystems>())
21-
=> _partialViewTreeService = partialViewTreeService;
17+
: base(partialViewTreeService)
18+
{
19+
}
2220

23-
[ActivatorUtilitiesConstructor]
24-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
21+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2522
public AncestorsPartialViewTreeController(IPartialViewTreeService partialViewTreeService, FileSystems fileSystems)
26-
: base(partialViewTreeService, fileSystems) =>
27-
_partialViewTreeService = partialViewTreeService;
23+
: base(partialViewTreeService, fileSystems)
24+
{
25+
}
2826

29-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
27+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
3028
public AncestorsPartialViewTreeController(FileSystems fileSystems)
31-
: this(StaticServiceProvider.Instance.GetRequiredService<IPartialViewTreeService>(), fileSystems)
29+
: base(fileSystems)
3230
{
3331
}
3432

src/Umbraco.Cms.Api.Management/Controllers/PartialView/Tree/ChildrenPartialViewTreeController.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.DependencyInjection;
5-
using Umbraco.Cms.Core.IO;
65
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
76
using Umbraco.Cms.Api.Management.Services.FileSystem;
87
using Umbraco.Cms.Api.Management.ViewModels.Tree;
9-
using Umbraco.Cms.Core.DependencyInjection;
8+
using Umbraco.Cms.Core.IO;
109

1110
namespace Umbraco.Cms.Api.Management.Controllers.PartialView.Tree;
1211

1312
[ApiVersion("1.0")]
1413
public class ChildrenPartialViewTreeController : PartialViewTreeControllerBase
1514
{
16-
private readonly IPartialViewTreeService _partialViewTreeService;
17-
1815
// TODO Remove the static service provider, and replace with base when the other constructors are obsoleted.
16+
[ActivatorUtilitiesConstructor]
1917
public ChildrenPartialViewTreeController(IPartialViewTreeService partialViewTreeService)
20-
: this(partialViewTreeService, StaticServiceProvider.Instance.GetRequiredService<FileSystems>())
21-
=> _partialViewTreeService = partialViewTreeService;
18+
: base(partialViewTreeService)
19+
{
20+
}
2221

23-
[ActivatorUtilitiesConstructor]
24-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
22+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2523
public ChildrenPartialViewTreeController(IPartialViewTreeService partialViewTreeService, FileSystems fileSystems)
26-
: base(partialViewTreeService, fileSystems) =>
27-
_partialViewTreeService = partialViewTreeService;
24+
: base(partialViewTreeService, fileSystems)
25+
{
26+
}
2827

29-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
28+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
3029
public ChildrenPartialViewTreeController(FileSystems fileSystems)
31-
: this(StaticServiceProvider.Instance.GetRequiredService<IPartialViewTreeService>(), fileSystems)
30+
: base(fileSystems)
3231
{
3332
}
3433

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using Microsoft.AspNetCore.Authorization;
22
using Microsoft.AspNetCore.Mvc;
3-
using Microsoft.Extensions.DependencyInjection;
43
using Umbraco.Cms.Api.Management.Controllers.Tree;
54
using Umbraco.Cms.Api.Management.Routing;
65
using Umbraco.Cms.Api.Management.Services.FileSystem;
76
using Umbraco.Cms.Core;
8-
using Umbraco.Cms.Core.DependencyInjection;
97
using Umbraco.Cms.Core.IO;
108
using Umbraco.Cms.Web.Common.Authorization;
119

@@ -16,30 +14,28 @@ namespace Umbraco.Cms.Api.Management.Controllers.PartialView.Tree;
1614
[Authorize(Policy = AuthorizationPolicies.TreeAccessPartialViews)]
1715
public class PartialViewTreeControllerBase : FileSystemTreeControllerBase
1816
{
19-
private readonly IPartialViewTreeService _partialViewTreeService;
20-
2117
// TODO Remove the static service provider, and replace with base when the other constructors are obsoleted.
2218
public PartialViewTreeControllerBase(IPartialViewTreeService partialViewTreeService)
23-
: this(partialViewTreeService, StaticServiceProvider.Instance.GetRequiredService<FileSystems>()) =>
24-
_partialViewTreeService = partialViewTreeService;
19+
: base(partialViewTreeService)
20+
{
21+
FileSystem = null!;
22+
}
2523

26-
// FileSystem is required therefore, we can't remove it without some wizadry. When obsoletion is due, remove this.
27-
[ActivatorUtilitiesConstructor]
28-
[Obsolete("Scheduled for removal in Umbraco 18.")]
24+
// FileSystem is required therefore, we can't remove it without some wizardry. When obsoletion is due, remove this.
25+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2926
public PartialViewTreeControllerBase(IPartialViewTreeService partialViewTreeService, FileSystems fileSystems)
3027
: base(partialViewTreeService)
3128
{
32-
_partialViewTreeService = partialViewTreeService;
3329
FileSystem = fileSystems.PartialViewsFileSystem ??
3430
throw new ArgumentException("Missing scripts file system", nameof(fileSystems));
3531
}
3632

37-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 18.")]
33+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
3834
public PartialViewTreeControllerBase(FileSystems fileSystems)
39-
: this(StaticServiceProvider.Instance.GetRequiredService<IPartialViewTreeService>())
35+
: base()
4036
=> FileSystem = fileSystems.PartialViewsFileSystem ??
4137
throw new ArgumentException("Missing scripts file system", nameof(fileSystems));
4238

43-
[Obsolete("Included in the service class. Scheduled to be removed in Umbraco 18.")]
39+
[Obsolete("Included in the service class. Scheduled to be removed in Umbraco 19.")]
4440
protected override IFileSystem FileSystem { get; }
4541
}

src/Umbraco.Cms.Api.Management/Controllers/PartialView/Tree/RootPartialViewTreeController.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.DependencyInjection;
5-
using Umbraco.Cms.Core.IO;
65
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
76
using Umbraco.Cms.Api.Management.Services.FileSystem;
87
using Umbraco.Cms.Api.Management.ViewModels.Tree;
9-
using Umbraco.Cms.Core.DependencyInjection;
8+
using Umbraco.Cms.Core.IO;
109

1110
namespace Umbraco.Cms.Api.Management.Controllers.PartialView.Tree;
1211

1312
[ApiVersion("1.0")]
1413
public class RootPartialViewTreeController : PartialViewTreeControllerBase
1514
{
16-
private readonly IPartialViewTreeService _partialViewTreeService;
17-
1815
// TODO Remove the static service provider, and replace with base when the other constructors are obsoleted.
16+
[ActivatorUtilitiesConstructor]
1917
public RootPartialViewTreeController(IPartialViewTreeService partialViewTreeService)
20-
: this(partialViewTreeService, StaticServiceProvider.Instance.GetRequiredService<FileSystems>())
21-
=> _partialViewTreeService = partialViewTreeService;
18+
: base(partialViewTreeService)
19+
{
20+
}
2221

23-
[ActivatorUtilitiesConstructor]
24-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
22+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2523
public RootPartialViewTreeController(IPartialViewTreeService partialViewTreeService, FileSystems fileSystems)
26-
: base(partialViewTreeService, fileSystems) =>
27-
_partialViewTreeService = partialViewTreeService;
24+
: base(partialViewTreeService, fileSystems)
25+
{
26+
}
2827

29-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
28+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
3029
public RootPartialViewTreeController(FileSystems fileSystems)
31-
: this(StaticServiceProvider.Instance.GetRequiredService<IPartialViewTreeService>(), fileSystems)
30+
: base(fileSystems)
3231
{
3332
}
3433

src/Umbraco.Cms.Api.Management/Controllers/PartialView/Tree/SiblingsPartialViewTreeController.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
1-
using Microsoft.AspNetCore.Http;
1+
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Mvc;
33
using Microsoft.Extensions.DependencyInjection;
44
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
55
using Umbraco.Cms.Api.Management.Services.FileSystem;
66
using Umbraco.Cms.Api.Management.ViewModels.Tree;
7-
using Umbraco.Cms.Core.DependencyInjection;
87
using Umbraco.Cms.Core.IO;
98

109
namespace Umbraco.Cms.Api.Management.Controllers.PartialView.Tree;
1110

1211
public class SiblingsPartialViewTreeController : PartialViewTreeControllerBase
1312
{
14-
private readonly IPartialViewTreeService _partialViewTreeService;
15-
1613
// TODO Remove the static service provider, and replace with base when the other constructors are obsoleted.
14+
[ActivatorUtilitiesConstructor]
1715
public SiblingsPartialViewTreeController(IPartialViewTreeService partialViewTreeService)
18-
: this(partialViewTreeService, StaticServiceProvider.Instance.GetRequiredService<FileSystems>())
19-
=> _partialViewTreeService = partialViewTreeService;
16+
: base(partialViewTreeService)
17+
{
18+
}
2019

21-
[ActivatorUtilitiesConstructor]
22-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
20+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2321
public SiblingsPartialViewTreeController(IPartialViewTreeService partialViewTreeService, FileSystems fileSystems)
24-
: base(partialViewTreeService, fileSystems) =>
25-
_partialViewTreeService = partialViewTreeService;
22+
: base(partialViewTreeService, fileSystems)
23+
{
24+
}
2625

27-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
26+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2827
public SiblingsPartialViewTreeController(FileSystems fileSystems)
29-
: this(StaticServiceProvider.Instance.GetRequiredService<IPartialViewTreeService>(), fileSystems)
28+
: base(fileSystems)
3029
{
3130
}
3231

src/Umbraco.Cms.Api.Management/Controllers/Script/Tree/AncestorsScriptTreeController.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.DependencyInjection;
55
using Umbraco.Cms.Api.Management.Services.FileSystem;
66
using Umbraco.Cms.Api.Management.ViewModels.Tree;
7-
using Umbraco.Cms.Core.DependencyInjection;
87
using Umbraco.Cms.Core.IO;
98

109
namespace Umbraco.Cms.Api.Management.Controllers.Script.Tree;
1110

1211
[ApiVersion("1.0")]
1312
public class AncestorsScriptTreeController : ScriptTreeControllerBase
1413
{
15-
private readonly IScriptTreeService _scriptTreeService;
16-
1714
// TODO Remove the static service provider, and replace with base when the other constructors are obsoleted.
15+
[ActivatorUtilitiesConstructor]
1816
public AncestorsScriptTreeController(IScriptTreeService scriptTreeService)
19-
: this(scriptTreeService, StaticServiceProvider.Instance.GetRequiredService<FileSystems>())
20-
=> _scriptTreeService = scriptTreeService;
17+
: base(scriptTreeService)
18+
{
19+
}
2120

22-
[ActivatorUtilitiesConstructor]
23-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
21+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2422
public AncestorsScriptTreeController(IScriptTreeService scriptTreeService, FileSystems fileSystems)
25-
: base(scriptTreeService, fileSystems) =>
26-
_scriptTreeService = scriptTreeService;
23+
: base(scriptTreeService, fileSystems)
24+
{
25+
}
2726

28-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
27+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2928
public AncestorsScriptTreeController(FileSystems fileSystems)
30-
: this(StaticServiceProvider.Instance.GetRequiredService<IScriptTreeService>(), fileSystems)
29+
: base(fileSystems)
3130
{
3231
}
3332

src/Umbraco.Cms.Api.Management/Controllers/Script/Tree/ChildrenScriptTreeController.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.DependencyInjection;
5-
using Umbraco.Cms.Core.IO;
65
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
76
using Umbraco.Cms.Api.Management.Services.FileSystem;
87
using Umbraco.Cms.Api.Management.ViewModels.Tree;
9-
using Umbraco.Cms.Core.DependencyInjection;
8+
using Umbraco.Cms.Core.IO;
109

1110
namespace Umbraco.Cms.Api.Management.Controllers.Script.Tree;
1211

1312
[ApiVersion("1.0")]
1413
public class ChildrenScriptTreeController : ScriptTreeControllerBase
1514
{
16-
private readonly IScriptTreeService _scriptTreeService;
17-
1815
// TODO Remove the static service provider, and replace with base when the other constructors are obsoleted.
16+
[ActivatorUtilitiesConstructor]
1917
public ChildrenScriptTreeController(IScriptTreeService scriptTreeService)
20-
: this(scriptTreeService, StaticServiceProvider.Instance.GetRequiredService<FileSystems>())
21-
=> _scriptTreeService = scriptTreeService;
18+
: base(scriptTreeService)
19+
{
20+
}
2221

23-
[ActivatorUtilitiesConstructor]
24-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
22+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2523
public ChildrenScriptTreeController(IScriptTreeService scriptTreeService, FileSystems fileSystems)
26-
: base(scriptTreeService, fileSystems) =>
27-
_scriptTreeService = scriptTreeService;
24+
: base(scriptTreeService, fileSystems)
25+
{
26+
}
2827

29-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
28+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
3029
public ChildrenScriptTreeController(FileSystems fileSystems)
31-
: this(StaticServiceProvider.Instance.GetRequiredService<IScriptTreeService>(), fileSystems)
30+
: base(fileSystems)
3231
{
3332
}
3433

src/Umbraco.Cms.Api.Management/Controllers/Script/Tree/RootScriptTreeController.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
using Asp.Versioning;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.DependencyInjection;
5-
using Umbraco.Cms.Core.IO;
65
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
76
using Umbraco.Cms.Api.Management.Services.FileSystem;
87
using Umbraco.Cms.Api.Management.ViewModels.Tree;
9-
using Umbraco.Cms.Core.DependencyInjection;
8+
using Umbraco.Cms.Core.IO;
109

1110
namespace Umbraco.Cms.Api.Management.Controllers.Script.Tree;
1211

1312
[ApiVersion("1.0")]
1413
public class RootScriptTreeController : ScriptTreeControllerBase
1514
{
16-
private readonly IScriptTreeService _scriptTreeService;
17-
1815
// TODO Remove the static service provider, and replace with base when the other constructors are obsoleted.
16+
[ActivatorUtilitiesConstructor]
1917
public RootScriptTreeController(IScriptTreeService scriptTreeService)
20-
: this(scriptTreeService, StaticServiceProvider.Instance.GetRequiredService<FileSystems>())
21-
=> _scriptTreeService = scriptTreeService;
18+
: base(scriptTreeService)
19+
{
20+
}
2221

23-
[ActivatorUtilitiesConstructor]
24-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
22+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
2523
public RootScriptTreeController(IScriptTreeService scriptTreeService, FileSystems fileSystems)
26-
: base(scriptTreeService, fileSystems) =>
27-
_scriptTreeService = scriptTreeService;
24+
: base(scriptTreeService, fileSystems)
25+
{
26+
}
2827

29-
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 19")]
28+
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
3029
public RootScriptTreeController(FileSystems fileSystems)
31-
: this(StaticServiceProvider.Instance.GetRequiredService<IScriptTreeService>(), fileSystems)
30+
: base(fileSystems)
3231
{
3332
}
3433

0 commit comments

Comments
 (0)