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.
This commit is contained in:
Andy Butland
2025-10-22 16:20:20 +02:00
parent 1bf53f3554
commit 04df2652f5
16 changed files with 251 additions and 236 deletions

View File

@@ -1,11 +1,9 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Api.Management.Controllers.Tree;
using Umbraco.Cms.Api.Management.Routing;
using Umbraco.Cms.Api.Management.Services.FileSystem;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Web.Common.Authorization;
@@ -16,30 +14,28 @@ namespace Umbraco.Cms.Api.Management.Controllers.Script.Tree;
[Authorize(Policy = AuthorizationPolicies.TreeAccessScripts)]
public class ScriptTreeControllerBase : FileSystemTreeControllerBase
{
private readonly IScriptTreeService _scriptTreeService;
// TODO Remove the static service provider, and replace with base when the other constructors are obsoleted.
public ScriptTreeControllerBase(IScriptTreeService scriptTreeService)
: this(scriptTreeService, StaticServiceProvider.Instance.GetRequiredService<FileSystems>()) =>
_scriptTreeService = scriptTreeService;
: base(scriptTreeService)
{
FileSystem = null!;
}
// FileSystem is required therefore, we can't remove it without some wizadry. When obsoletion is due, remove this.
[ActivatorUtilitiesConstructor]
[Obsolete("Scheduled for removal in Umbraco 18.")]
// FileSystem is required therefore, we can't remove it without some wizardry. When obsoletion is due, remove this.
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
public ScriptTreeControllerBase(IScriptTreeService scriptTreeService, FileSystems fileSystems)
: base(scriptTreeService)
{
_scriptTreeService = scriptTreeService;
FileSystem = fileSystems.ScriptsFileSystem ??
throw new ArgumentException("Missing scripts file system", nameof(fileSystems));
}
[Obsolete("Please use the other constructor. Scheduled to be removed in Umbraco 18.")]
[Obsolete("Please use the constructor taking all parameters. Scheduled to be removed in Umbraco 19.")]
public ScriptTreeControllerBase(FileSystems fileSystems)
: this(StaticServiceProvider.Instance.GetRequiredService<IScriptTreeService>())
: base()
=> FileSystem = fileSystems.ScriptsFileSystem ??
throw new ArgumentException("Missing scripts file system", nameof(fileSystems));
[Obsolete("Included in the service class. Scheduled to be removed in Umbraco 18.")]
[Obsolete("Included in the service class. Scheduled to be removed in Umbraco 19.")]
protected override IFileSystem FileSystem { get; }
}