-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce path provider and resolver for the Content Delivery API (#1…
- Loading branch information
Showing
15 changed files
with
188 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Umbraco.Cms.Core.Models.PublishedContent; | ||
using Umbraco.Cms.Core.Routing; | ||
|
||
namespace Umbraco.Cms.Core.DeliveryApi; | ||
|
||
// NOTE: left unsealed on purpose so it is extendable. | ||
public class ApiContentPathProvider : IApiContentPathProvider | ||
{ | ||
private readonly IPublishedUrlProvider _publishedUrlProvider; | ||
|
||
public ApiContentPathProvider(IPublishedUrlProvider publishedUrlProvider) | ||
=> _publishedUrlProvider = publishedUrlProvider; | ||
|
||
public virtual string? GetContentPath(IPublishedContent content, string? culture) | ||
=> _publishedUrlProvider.GetUrl(content, UrlMode.Relative, culture); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Umbraco.Cms.Core.Models.PublishedContent; | ||
using Umbraco.Extensions; | ||
|
||
namespace Umbraco.Cms.Core.DeliveryApi; | ||
|
||
// NOTE: left unsealed on purpose so it is extendable. | ||
public class ApiContentPathResolver : IApiContentPathResolver | ||
{ | ||
private readonly IRequestRoutingService _requestRoutingService; | ||
private readonly IApiPublishedContentCache _apiPublishedContentCache; | ||
|
||
public ApiContentPathResolver(IRequestRoutingService requestRoutingService, IApiPublishedContentCache apiPublishedContentCache) | ||
{ | ||
_requestRoutingService = requestRoutingService; | ||
_apiPublishedContentCache = apiPublishedContentCache; | ||
} | ||
|
||
public virtual IPublishedContent? ResolveContentPath(string path) | ||
{ | ||
path = path.EnsureStartsWith("/"); | ||
|
||
var contentRoute = _requestRoutingService.GetContentRoute(path); | ||
IPublishedContent? contentItem = _apiPublishedContentCache.GetByRoute(contentRoute); | ||
return contentItem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Umbraco.Cms.Core.Models.PublishedContent; | ||
|
||
namespace Umbraco.Cms.Core.DeliveryApi; | ||
|
||
public interface IApiContentPathProvider | ||
{ | ||
string? GetContentPath(IPublishedContent content, string? culture); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Umbraco.Cms.Core.Models.PublishedContent; | ||
|
||
namespace Umbraco.Cms.Core.DeliveryApi; | ||
|
||
public interface IApiContentPathResolver | ||
{ | ||
IPublishedContent? ResolveContentPath(string path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.