Netcore: Move files from Web/Routing to Abstractions/Routing (#7642)
* AB4951 - Move routing files to abstractions * Changed UriUtility from static to instance * Moved more files from Routing in web to Abstractions * Moved UrlProvider to Abstractions * Moved PublishedRequest to Abstractions
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using Examine;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -50,8 +51,8 @@ namespace Umbraco.Web
|
||||
Current.Configs.Settings().WebRouting.DisableAlternativeTemplates,
|
||||
Current.Configs.Settings().WebRouting.ValidateAlternativeTemplates,
|
||||
templateId);
|
||||
|
||||
}
|
||||
|
||||
public static bool IsAllowedTemplate(this IPublishedContent content, string templateAlias)
|
||||
{
|
||||
return content.IsAllowedTemplate(
|
||||
@@ -284,7 +285,7 @@ namespace Umbraco.Web
|
||||
{
|
||||
return parentNodes.DescendantsOrSelf<T>(VariationContextAccessor, culture);
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<IPublishedContent> Descendants(this IPublishedContent content, string culture = null)
|
||||
{
|
||||
return content.Descendants(VariationContextAccessor, culture);
|
||||
@@ -700,38 +701,28 @@ namespace Umbraco.Web
|
||||
#region Url
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url of the content item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>If the content item is a document, then this method returns the url of the
|
||||
/// document. If it is a media, then this methods return the media url for the
|
||||
/// 'umbracoFile' property. Use the MediaUrl() method to get the media url for other
|
||||
/// properties.</para>
|
||||
/// <para>The value of this property is contextual. It depends on the 'current' request uri,
|
||||
/// if any. In addition, when the content type is multi-lingual, this is the url for the
|
||||
/// specified culture. Otherwise, it is the invariant url.</para>
|
||||
/// </remarks>
|
||||
public static string Url(this IPublishedContent content, string culture = null, UrlMode mode = UrlMode.Default)
|
||||
{
|
||||
var umbracoContext = Composing.Current.UmbracoContext;
|
||||
/// Gets the url of the content item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>If the content item is a document, then this method returns the url of the
|
||||
/// document. If it is a media, then this methods return the media url for the
|
||||
/// 'umbracoFile' property. Use the MediaUrl() method to get the media url for other
|
||||
/// properties.</para>
|
||||
/// <para>The value of this property is contextual. It depends on the 'current' request uri,
|
||||
/// if any. In addition, when the content type is multi-lingual, this is the url for the
|
||||
/// specified culture. Otherwise, it is the invariant url.</para>
|
||||
/// </remarks>
|
||||
public static string Url(this IPublishedContent content, string culture = null, UrlMode mode = UrlMode.Default)
|
||||
{
|
||||
var umbracoContext = Composing.Current.UmbracoContext;
|
||||
|
||||
if (umbracoContext == null)
|
||||
throw new InvalidOperationException("Cannot resolve a Url when Current.UmbracoContext is null.");
|
||||
if (umbracoContext.UrlProvider == null)
|
||||
throw new InvalidOperationException("Cannot resolve a Url when Current.UmbracoContext.UrlProvider is null.");
|
||||
|
||||
switch (content.ContentType.ItemType)
|
||||
{
|
||||
case PublishedItemType.Content:
|
||||
return umbracoContext.UrlProvider.GetUrl(content, mode, culture);
|
||||
if (umbracoContext == null)
|
||||
throw new InvalidOperationException("Cannot resolve a Url when Current.UmbracoContext is null.");
|
||||
|
||||
case PublishedItemType.Media:
|
||||
return umbracoContext.UrlProvider.GetMediaUrl(content, mode, culture, Constants.Conventions.Media.File);
|
||||
return content.Url(umbracoContext.UrlProvider, culture, mode);
|
||||
}
|
||||
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user