diff --git a/src/Umbraco.Abstractions/IUmbracoContext.cs b/src/Umbraco.Abstractions/IUmbracoContext.cs index 88dd7c2009..93d830ef3e 100644 --- a/src/Umbraco.Abstractions/IUmbracoContext.cs +++ b/src/Umbraco.Abstractions/IUmbracoContext.cs @@ -16,11 +16,6 @@ namespace Umbraco.Web /// DateTime ObjectCreated { get; } - /// - /// This is used internally for debugging and also used to define anything required to distinguish this request from another. - /// - Guid UmbracoRequestId { get; } - /// /// Gets the WebSecurity class /// @@ -83,40 +78,6 @@ namespace Umbraco.Web /// bool InPreviewMode { get; } - /// - /// Gets the url of a content identified by its identifier. - /// - /// The content identifier. - /// - /// The url for the content. - string Url(int contentId, string culture = null); - - /// - /// Gets the url of a content identified by its identifier. - /// - /// The content identifier. - /// - /// The url for the content. - string Url(Guid contentId, string culture = null); - - /// - /// Gets the url of a content identified by its identifier, in a specified mode. - /// - /// The content identifier. - /// The mode. - /// - /// The url for the content. - string Url(int contentId, UrlMode mode, string culture = null); - - /// - /// Gets the url of a content identified by its identifier, in a specified mode. - /// - /// The content identifier. - /// The mode. - /// - /// The url for the content. - string Url(Guid contentId, UrlMode mode, string culture = null); - IDisposable ForcedPreview(bool preview); void Dispose(); } diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index ce90955823..12ff3952fd 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -411,7 +411,7 @@ namespace Umbraco.Web.Editors /// public HttpResponseMessage GetNiceUrl(int id) { - var url = UmbracoContext.Url(id); + var url = PublishedUrlProvider.GetUrl(id); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(url, Encoding.UTF8, "text/plain"); return response; @@ -424,7 +424,7 @@ namespace Umbraco.Web.Editors /// public HttpResponseMessage GetNiceUrl(Guid id) { - var url = UmbracoContext.Url(id); + var url = PublishedUrlProvider.GetUrl(id); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(url, Encoding.UTF8, "text/plain"); return response; diff --git a/src/Umbraco.Web/Editors/EntityController.cs b/src/Umbraco.Web/Editors/EntityController.cs index ee8d08fc07..0d72e08318 100644 --- a/src/Umbraco.Web/Editors/EntityController.cs +++ b/src/Umbraco.Web/Editors/EntityController.cs @@ -268,7 +268,7 @@ namespace Umbraco.Web.Editors if (type == UmbracoEntityTypes.Document) { - var foundUrl = UmbracoContext.Url(id, culture); + var foundUrl = PublishedUrlProvider.GetUrl(id, culture: culture); if (string.IsNullOrEmpty(foundUrl) == false && foundUrl != "#") { returnUrl = foundUrl; diff --git a/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs b/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs index a905320cc5..11b91ffc90 100644 --- a/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs +++ b/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs @@ -10,6 +10,7 @@ using Umbraco.Core.Persistence; using Umbraco.Core.Services; using Umbraco.Examine; using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Routing; using Umbraco.Web.Trees; namespace Umbraco.Web.Search @@ -20,26 +21,28 @@ namespace Umbraco.Web.Search /// public class UmbracoTreeSearcher { - private readonly IUmbracoContext _umbracoContext; private readonly ILocalizationService _languageService; private readonly IEntityService _entityService; private readonly UmbracoMapper _mapper; private readonly ISqlContext _sqlContext; private readonly IBackOfficeExamineSearcher _backOfficeExamineSearcher; + private readonly IPublishedUrlProvider _publishedUrlProvider; - public UmbracoTreeSearcher(IUmbracoContext umbracoContext, + public UmbracoTreeSearcher( ILocalizationService languageService, IEntityService entityService, UmbracoMapper mapper, - ISqlContext sqlContext, IBackOfficeExamineSearcher backOfficeExamineSearcher) + ISqlContext sqlContext, + IBackOfficeExamineSearcher backOfficeExamineSearcher, + IPublishedUrlProvider publishedUrlProvider) { - _umbracoContext = umbracoContext; _languageService = languageService; _entityService = entityService; _mapper = mapper; _sqlContext = sqlContext; _backOfficeExamineSearcher = backOfficeExamineSearcher; + _publishedUrlProvider = publishedUrlProvider; } /// @@ -157,11 +160,11 @@ namespace Umbraco.Web.Search //if it varies by culture, return the default language URL if (result.Values.TryGetValue(UmbracoExamineFieldNames.VariesByCultureFieldName, out var varies) && varies == "y") { - entity.AdditionalData["Url"] = _umbracoContext.Url(intId.Result, defaultLang); + entity.AdditionalData["Url"] = _publishedUrlProvider.GetUrl(intId.Result, culture: defaultLang); } else { - entity.AdditionalData["Url"] = _umbracoContext.Url(intId.Result); + entity.AdditionalData["Url"] = _publishedUrlProvider.GetUrl(intId.Result); } } diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index 4cafc1e4b2..703f626bcf 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -169,56 +169,6 @@ namespace Umbraco.Web private set => _previewing = value; } - #region Urls - - /// - /// Gets the url of a content identified by its identifier. - /// - /// The content identifier. - /// - /// The url for the content. - public string Url(int contentId, string culture = null) - { - return _publishedUrlProvider.GetUrl(contentId, culture: culture); - } - - /// - /// Gets the url of a content identified by its identifier. - /// - /// The content identifier. - /// - /// The url for the content. - public string Url(Guid contentId, string culture = null) - { - return _publishedUrlProvider.GetUrl(contentId, culture: culture); - } - - /// - /// Gets the url of a content identified by its identifier, in a specified mode. - /// - /// The content identifier. - /// The mode. - /// - /// The url for the content. - public string Url(int contentId, UrlMode mode, string culture = null) - { - return _publishedUrlProvider.GetUrl(contentId, mode, culture); - } - - /// - /// Gets the url of a content identified by its identifier, in a specified mode. - /// - /// The content identifier. - /// The mode. - /// - /// The url for the content. - public string Url(Guid contentId, UrlMode mode, string culture = null) - { - return _publishedUrlProvider.GetUrl(contentId, mode, culture); - } - - #endregion - public string PreviewToken { get