Skip to content

Commit

Permalink
fix app resources not loading when using old ToSic.Sxc.Web.IPageService
Browse files Browse the repository at this point in the history
  • Loading branch information
iJungleboy committed Jun 27, 2024
1 parent f901cb6 commit ac4eef6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ToSic.Sxc.Web;
using ToSic.Sxc.Web.Internal.PageService;
using ToSic.Sxc.Web.PageService;

namespace ToSic.Sxc.Tests.PageProperty
{
Expand Down
3 changes: 2 additions & 1 deletion Src/Sxc/ToSic.Sxc/Startup/RegisterSxcObsolete.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using ToSic.Sxc.Web.PageService;
using ToSic.Sxc.Web;

#pragma warning disable CS0618
#pragma warning disable CS0612

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using ToSic.Sxc.Services;
using ToSic.Sxc.Services.Internal;
using ToSic.Sxc.Web.Internal.PageService;
using ToSic.Sxc.Web.PageService;

namespace ToSic.Sxc.Web.Internal.ContentSecurityPolicy;

Expand Down
22 changes: 20 additions & 2 deletions Src/Sxc/ToSic.Sxc/Web/Old/WebPageServiceObsolete.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
using ToSic.Razor.Blade;
using ToSic.Sxc.Code.Internal;

namespace ToSic.Sxc.Web.PageService;
namespace ToSic.Sxc.Web;

/// <summary>
/// This is the obsolete version of the PageService, which is needed to keep old Apps working which used this.
/// The apps will get it using `var page = GetService{ToSic.Sxc.Web.IPageService}()` or similar.
/// </summary>
/// <param name="pageServiceImplementation"></param>
[Obsolete]
internal class WebPageServiceObsolete(Services.IPageService pageServiceImplementation) : ToSic.Sxc.Web.IPageService
internal class WebPageServiceObsolete(Services.IPageService pageServiceImplementation) : IPageService, INeedsCodeApiService
{
/// <summary>
/// Forward execution context to the actual implementation.
///
/// Fixes bug https://github.com/2sic/2sxc/issues/3424
/// </summary>
/// <param name="codeRoot"></param>
public void ConnectToRoot(ICodeApiService codeRoot)
{
(pageServiceImplementation as INeedsCodeApiService)?.ConnectToRoot(codeRoot);
}

public string SetBase(string url = null)
{
return pageServiceImplementation.SetBase(url);
Expand Down Expand Up @@ -77,4 +94,5 @@ public string Activate(params string[] keys)
{
return pageServiceImplementation.Activate(keys);
}

}

0 comments on commit ac4eef6

Please sign in to comment.