removes some usages of singletons
This commit is contained in:
@@ -68,7 +68,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
expression => expression.MapFrom(content =>
|
||||
UmbracoContext.Current == null
|
||||
? new[] {"Cannot generate urls without a current Umbraco Context"}
|
||||
: content.GetContentUrls()))
|
||||
: content.GetContentUrls(UmbracoContext.Current)))
|
||||
.ForMember(display => display.Properties, expression => expression.Ignore())
|
||||
.ForMember(display => display.TreeNodeUrl, expression => expression.Ignore())
|
||||
.ForMember(display => display.Notifications, expression => expression.Ignore())
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
using umbraco;
|
||||
|
||||
@@ -10,22 +11,26 @@ namespace Umbraco.Web.Routing
|
||||
/// Gets the URLs for the content item
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="umbracoContext"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Use this when displaying URLs, if there are errors genertaing the urls the urls themselves will
|
||||
/// contain the errors.
|
||||
/// </remarks>
|
||||
public static IEnumerable<string> GetContentUrls(this IContent content)
|
||||
public static IEnumerable<string> GetContentUrls(this IContent content, UmbracoContext umbracoContext)
|
||||
{
|
||||
if (content == null) throw new ArgumentNullException("content");
|
||||
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
|
||||
|
||||
var urls = new List<string>();
|
||||
|
||||
if (content.HasPublishedVersion() == false)
|
||||
{
|
||||
urls.Add(ui.Text("content", "itemNotPublished", UmbracoContext.Current.Security.CurrentUser));
|
||||
urls.Add(ui.Text("content", "itemNotPublished", umbracoContext.Security.CurrentUser));
|
||||
return urls;
|
||||
}
|
||||
|
||||
var urlProvider = UmbracoContext.Current.RoutingContext.UrlProvider;
|
||||
var urlProvider = umbracoContext.RoutingContext.UrlProvider;
|
||||
var url = urlProvider.GetUrl(content.Id);
|
||||
if (url == "#")
|
||||
{
|
||||
@@ -39,9 +44,9 @@ namespace Umbraco.Web.Routing
|
||||
while (parent != null && parent.Published);
|
||||
|
||||
if (parent == null) // oops - internal error
|
||||
urls.Add(ui.Text("content", "parentNotPublishedAnomaly", UmbracoContext.Current.Security.CurrentUser));
|
||||
urls.Add(ui.Text("content", "parentNotPublishedAnomaly", umbracoContext.Security.CurrentUser));
|
||||
else
|
||||
urls.Add(ui.Text("content", "parentNotPublished", parent.Name, UmbracoContext.Current.Security.CurrentUser));
|
||||
urls.Add(ui.Text("content", "parentNotPublished", parent.Name, umbracoContext.Security.CurrentUser));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user