Refactor IPublishedContent.Children()
This commit is contained in:
@@ -160,8 +160,13 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// <summary>
|
||||
/// Gets the children of the content item.
|
||||
/// </summary>
|
||||
/// <remarks>Children are sorted by their sortOrder.</remarks>
|
||||
IEnumerable<IPublishedContent> Children { get; }
|
||||
/// <param name="culture">The specific culture to get the url children for. If null is used the current culture is used (Default is null).</param>
|
||||
/// <remarks>
|
||||
/// <para>Gets children that are available for the specified culture.</para>
|
||||
/// <para>Children are sorted by their sortOrder.</para>
|
||||
/// </remarks>
|
||||
// FIXME: can culture be '*'?
|
||||
IEnumerable<IPublishedContent> Children(string culture = null);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
public virtual IPublishedContent Parent() => _content.Parent();
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IEnumerable<IPublishedContent> Children => _content.Children;
|
||||
public virtual IEnumerable<IPublishedContent> Children(string culture = null) => _content.Children(culture);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -172,9 +172,9 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
child1, child2
|
||||
});
|
||||
|
||||
Assert.AreEqual(2, dicDoc.Children.Count());
|
||||
Assert.AreEqual(222333, dicDoc.Children.ElementAt(0).Id);
|
||||
Assert.AreEqual(444555, dicDoc.Children.ElementAt(1).Id);
|
||||
Assert.AreEqual(2, dicDoc.Children().Count());
|
||||
Assert.AreEqual(222333, dicDoc.Children().ElementAt(0).Id);
|
||||
Assert.AreEqual(444555, dicDoc.Children().ElementAt(1).Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -229,9 +229,9 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
|
||||
DoAssert(doc, 2000, key, null, 2, "image1", "Image", 23, "Shannon", "Shannon", 33, 33, "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1);
|
||||
Assert.AreEqual(null, doc.Parent());
|
||||
Assert.AreEqual(2, doc.Children.Count());
|
||||
Assert.AreEqual(2001, doc.Children.ElementAt(0).Id);
|
||||
Assert.AreEqual(2002, doc.Children.ElementAt(1).Id);
|
||||
Assert.AreEqual(2, doc.Children().Count());
|
||||
Assert.AreEqual(2001, doc.Children().ElementAt(0).Id);
|
||||
Assert.AreEqual(2002, doc.Children().ElementAt(1).Id);
|
||||
}
|
||||
|
||||
private XmlDocument GetMediaXml()
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
|
||||
public override IEnumerable<IPublishedProperty> Properties => _properties;
|
||||
|
||||
public override IEnumerable<IPublishedContent> Children => _getChildren.Value;
|
||||
public override IEnumerable<IPublishedContent> Children(string culture = null) => _getChildren.Value;
|
||||
|
||||
public override IPublishedProperty GetProperty(string alias)
|
||||
{
|
||||
|
||||
@@ -75,13 +75,10 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
private bool _isDraft;
|
||||
|
||||
|
||||
public override IEnumerable<IPublishedContent> Children
|
||||
public override IEnumerable<IPublishedContent> Children(string culture = null)
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureNodeInitialized(andChildren: true);
|
||||
return _children;
|
||||
}
|
||||
EnsureNodeInitialized(andChildren: true);
|
||||
return _children;
|
||||
}
|
||||
|
||||
public override IPublishedProperty GetProperty(string alias)
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace Umbraco.Tests.Published
|
||||
public override bool IsDraft(string culture = null) => false;
|
||||
public override bool IsPublished(string culture = null) => true;
|
||||
public override IPublishedContent Parent() => null;
|
||||
public override IEnumerable<IPublishedContent> Children { get; }
|
||||
public override IEnumerable<IPublishedContent> Children(string culture = null) => Enumerable.Empty<IPublishedContent>();
|
||||
public override IPublishedContentType ContentType { get; }
|
||||
// ReSharper restore UnassignedGetOnlyAutoProperty
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
var doc = GetContent(true, 1);
|
||||
//change a doc type alias
|
||||
var c = (TestPublishedContent)doc.Children.ElementAt(0);
|
||||
var c = (TestPublishedContent)doc.Children().ElementAt(0);
|
||||
c.ContentType = new PublishedContentType(22, "DontMatch", PublishedItemType.Content, Enumerable.Empty<string>(), Enumerable.Empty<PublishedPropertyType>(), ContentVariation.Nothing);
|
||||
|
||||
var dt = doc.ChildrenAsTable(Current.Services, "Child");
|
||||
@@ -190,10 +190,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
IPublishedContent IPublishedContent.Parent() => Parent;
|
||||
|
||||
IEnumerable<IPublishedContent> IPublishedContent.Children
|
||||
{
|
||||
get { return Children; }
|
||||
}
|
||||
IEnumerable<IPublishedContent> IPublishedContent.Children(string culture = null) => Children;
|
||||
|
||||
public IPublishedContent Parent { get; set; }
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -177,10 +177,10 @@ namespace Umbraco.Tests.PublishedContent
|
||||
item3.SetUrlSegment("content-3");
|
||||
item3.SetUrl("/content-1/content-2/content-3");
|
||||
|
||||
item1.Children = new List<IPublishedContent> { item2 };
|
||||
item1.SetChildren(new List<IPublishedContent> { item2 });
|
||||
item2.SetParent(item1);
|
||||
|
||||
item2.Children = new List<IPublishedContent> { item3 };
|
||||
item2.SetChildren(new List<IPublishedContent> { item3 });
|
||||
item3.SetParent(item2);
|
||||
|
||||
cache.Add(item1);
|
||||
@@ -247,7 +247,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Do_Not_Get_Content_Recursively_Unless_Requested()
|
||||
{
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First();
|
||||
var value = content.Value("welcomeText2");
|
||||
Assert.IsNull(value);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Can_Get_Content_Recursively()
|
||||
{
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First();
|
||||
var value = content.Value("welcomeText2", fallback: Fallback.ToAncestors);
|
||||
Assert.AreEqual("Welcome", value);
|
||||
}
|
||||
@@ -263,7 +263,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Do_Not_Get_Content_Recursively_Unless_Requested2()
|
||||
{
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First().Children().First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First().Children().First();
|
||||
Assert.IsNull(content.GetProperty("welcomeText2"));
|
||||
var value = content.Value("welcomeText2");
|
||||
Assert.IsNull(value);
|
||||
@@ -272,7 +272,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Can_Get_Content_Recursively2()
|
||||
{
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First().Children().First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First().Children().First();
|
||||
Assert.IsNull(content.GetProperty("welcomeText2"));
|
||||
var value = content.Value("welcomeText2", fallback: Fallback.ToAncestors);
|
||||
Assert.AreEqual("Welcome", value);
|
||||
@@ -281,7 +281,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Can_Get_Content_Recursively3()
|
||||
{
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First().Children().First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First().Children().First();
|
||||
Assert.IsNull(content.GetProperty("noprop"));
|
||||
var value = content.Value("noprop", fallback: Fallback.ToAncestors);
|
||||
// property has no value but we still get the value (ie, the converter would do something)
|
||||
@@ -292,7 +292,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
public void Can_Get_Content_With_Recursive_Priority()
|
||||
{
|
||||
Current.VariationContextAccessor.VariationContext = new VariationContext("nl");
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First();
|
||||
|
||||
var value = content.Value("welcomeText", "nl", fallback: Fallback.To(Fallback.Ancestors, Fallback.Language));
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Can_Get_Content_With_Fallback_Language_Priority()
|
||||
{
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First();
|
||||
var value = content.Value("welcomeText", "nl", fallback: Fallback.ToLanguage);
|
||||
|
||||
// No Dutch value is directly assigned. Check has fallen back to English value from language variant.
|
||||
@@ -313,14 +313,14 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Throws_For_Non_Supported_Fallback()
|
||||
{
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First();
|
||||
Assert.Throws<NotSupportedException>(() => content.Value("welcomeText", "nl", fallback: Fallback.To(999)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Fallback_To_Default_Value()
|
||||
{
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First();
|
||||
|
||||
// no Dutch value is assigned, so getting null
|
||||
var value = content.Value("welcomeText", "nl");
|
||||
@@ -338,7 +338,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Can_Have_Custom_Default_Value()
|
||||
{
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children.First();
|
||||
var content = Current.UmbracoContext.ContentCache.GetAtRoot().First().Children().First();
|
||||
|
||||
// HACK: the value, pretend the converter would return something
|
||||
var prop = content.GetProperty("welcomeText") as SolidPublishedPropertyWithLanguageVariants;
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
var doc = GetNode(1173);
|
||||
|
||||
var items = doc.Children.Where(x => x.IsVisible()).ToIndexedArray();
|
||||
var items = doc.Children().Where(x => x.IsVisible()).ToIndexedArray();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
@@ -190,7 +190,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var doc = GetNode(1173);
|
||||
|
||||
var items = doc
|
||||
.Children
|
||||
.Children()
|
||||
.Where(x => x.IsVisible())
|
||||
.ToIndexedArray();
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var doc = GetNode(1173);
|
||||
var ct = doc.ContentType;
|
||||
|
||||
var items = doc.Children
|
||||
var items = doc.Children()
|
||||
.Select(x => x.CreateModel()) // linq, returns IEnumerable<IPublishedContent>
|
||||
|
||||
// only way around this is to make sure every IEnumerable<T> extension
|
||||
@@ -277,7 +277,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
var doc = GetNode(1173);
|
||||
|
||||
var items = doc.Children.Take(4).ToIndexedArray();
|
||||
var items = doc.Children().Take(4).ToIndexedArray();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
@@ -297,7 +297,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
var doc = GetNode(1173);
|
||||
|
||||
foreach (var d in doc.Children.Skip(1).ToIndexedArray())
|
||||
foreach (var d in doc.Children().Skip(1).ToIndexedArray())
|
||||
{
|
||||
if (d.Content.Id != 1176)
|
||||
{
|
||||
@@ -315,7 +315,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
var doc = GetNode(1173);
|
||||
|
||||
var items = doc.Children
|
||||
var items = doc.Children()
|
||||
.Concat(new[] { GetNode(1175), GetNode(4444) })
|
||||
.ToIndexedArray();
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var doc = GetNode(1046);
|
||||
|
||||
var found1 = doc.Children.GroupBy(x => x.ContentType.Alias).ToArray();
|
||||
var found1 = doc.Children().GroupBy(x => x.ContentType.Alias).ToArray();
|
||||
|
||||
Assert.AreEqual(2, found1.Length);
|
||||
Assert.AreEqual(2, found1.Single(x => x.Key.ToString() == "Home").Count());
|
||||
@@ -421,8 +421,8 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var doc = GetNode(1046);
|
||||
|
||||
var found1 = doc.Children.Where(x => x.ContentType.Alias == "CustomDocument");
|
||||
var found2 = doc.Children.Where(x => x.ContentType.Alias == "Home");
|
||||
var found1 = doc.Children().Where(x => x.ContentType.Alias == "CustomDocument");
|
||||
var found2 = doc.Children().Where(x => x.ContentType.Alias == "Home");
|
||||
|
||||
Assert.AreEqual(1, found1.Count());
|
||||
Assert.AreEqual(2, found2.Count());
|
||||
@@ -433,7 +433,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
var doc = GetNode(1173);
|
||||
|
||||
var ordered = doc.Children.OrderBy(x => x.UpdateDate);
|
||||
var ordered = doc.Children().OrderBy(x => x.UpdateDate);
|
||||
|
||||
var correctOrder = new[] { 1178, 1177, 1174, 1176 };
|
||||
for (var i = 0; i < correctOrder.Length; i++)
|
||||
|
||||
@@ -212,7 +212,9 @@ namespace Umbraco.Tests.PublishedContent
|
||||
private IPublishedContent _parent;
|
||||
public IPublishedContent Parent() => _parent;
|
||||
public void SetParent(IPublishedContent parent) => _parent = parent;
|
||||
public IEnumerable<IPublishedContent> Children { get; set; }
|
||||
private IEnumerable<IPublishedContent> _children;
|
||||
public IEnumerable<IPublishedContent> Children(string culture = null) => _children;
|
||||
public void SetChildren(IEnumerable<IPublishedContent> children) => _children = children;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -56,7 +56,9 @@ namespace Umbraco.Tests.TestHelpers.Stubs
|
||||
private IPublishedContent _parent;
|
||||
public IPublishedContent Parent() => _parent;
|
||||
public void SetParent(IPublishedContent parent) => _parent = parent;
|
||||
public IEnumerable<IPublishedContent> Children { get; set; }
|
||||
private IEnumerable<IPublishedContent> _children;
|
||||
public IEnumerable<IPublishedContent> Children(string culture = null) => _children;
|
||||
public void SetChildren(IEnumerable<IPublishedContent> children) => _children = children;
|
||||
|
||||
// copied from PublishedContentBase
|
||||
public IPublishedProperty GetProperty(string alias, bool recurse)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{
|
||||
@* Get the starting page *@
|
||||
var startNode = Umbraco.Content(startNodeId);
|
||||
var selection = startNode.Children.Where(x => x.IsVisible()).ToArray();
|
||||
var selection = startNode.Children().Where(x => x.IsVisible()).ToArray();
|
||||
|
||||
if (selection.Length > 0)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
- It then generates links so the visitor can go to each page
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).ToArray(); }
|
||||
@{ var selection = Model.Content.Children().Where(x => x.IsVisible()).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
- It then generates links so the visitor can go to each page
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderByDescending(x => x.CreateDate).ToArray(); }
|
||||
@{ var selection = Model.Content.Children().Where(x => x.IsVisible()).OrderByDescending(x => x.CreateDate).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
- It then generates links so the visitor can go to each page
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.Name).ToArray(); }
|
||||
@{ var selection = Model.Content.Children().Where(x => x.IsVisible()).OrderBy(x => x.Name).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
@if (propertyAlias != null)
|
||||
{
|
||||
var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.Value(propertyAlias.ToString())).ToArray();
|
||||
var selection = Model.Content.Children().Where(x => x.IsVisible()).OrderBy(x => x.Value(propertyAlias.ToString())).ToArray();
|
||||
|
||||
if (selection.Length > 0)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
the page currently being viewed by the website visitor, displayed as nested unordered HTML lists.
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).ToArray(); }
|
||||
@{ var selection = Model.Content.Children().Where(x => x.IsVisible()).ToArray(); }
|
||||
|
||||
@* Ensure that the Current Page has children *@
|
||||
@if (selection.Length > 0)
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
@* if this child page has any children, where the property umbracoNaviHide is not True *@
|
||||
@{
|
||||
var children = item.Children.Where(x => x.IsVisible()).ToArray();
|
||||
var children = item.Children().Where(x => x.IsVisible()).ToArray();
|
||||
if (children.Length > 0)
|
||||
{
|
||||
@* Call our helper to display the children *@
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
@* if the page has any children, where the property umbracoNaviHide is not True *@
|
||||
@{
|
||||
var children = item.Children.Where(x => x.IsVisible()).ToArray();
|
||||
var children = item.Children().Where(x => x.IsVisible()).ToArray();
|
||||
if (children.Length > 0)
|
||||
{
|
||||
@* Recurse and call our helper to display the children *@
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
{
|
||||
@* Get the media item associated with the id passed in *@
|
||||
var media = Umbraco.Media(mediaId);
|
||||
var selection = media.Children.ToArray();
|
||||
var selection = media.Children().ToArray();
|
||||
|
||||
if (selection.Length > 0)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
It also highlights the current active page/section in the navigation with the CSS class "current".
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Root().Children.Where(x => x.IsVisible()).ToArray(); }
|
||||
@{ var selection = Model.Content.Root().Children().Where(x => x.IsVisible()).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
const int maxLevelForSitemap = 4;
|
||||
|
||||
@* Select visible children *@
|
||||
var selection = node.Children.Where(x => x.IsVisible() && x.Level <= maxLevelForSitemap).ToArray();
|
||||
var selection = node.Children().Where(x => x.IsVisible() && x.Level <= maxLevelForSitemap).ToArray();
|
||||
|
||||
@* If any items are returned, render a list *@
|
||||
if (selection.Length > 0)
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace Umbraco.Web.Macros
|
||||
|
||||
public IPublishedContent Parent() => _parent;
|
||||
|
||||
public IEnumerable<IPublishedContent> Children => throw new NotImplementedException();
|
||||
public IEnumerable<IPublishedContent> Children(string culture = null) => throw new NotImplementedException();
|
||||
|
||||
public IEnumerable<IPublishedProperty> Properties => _properties;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace Umbraco.Web.Models
|
||||
public abstract IPublishedContent Parent();
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEnumerable<IPublishedContent> Children { get; }
|
||||
public abstract IEnumerable<IPublishedContent> Children(string culture = null);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// hideTopLevelNode = support legacy stuff, look for /*/path/to/node
|
||||
// else normal, look for /path/to/node
|
||||
content = hideTopLevelNode.Value
|
||||
? GetAtRoot(preview).SelectMany(x => x.Children).FirstOrDefault(x => x.UrlSegment(culture) == parts[0])
|
||||
? GetAtRoot(preview).SelectMany(x => x.Children(culture)).FirstOrDefault(x => x.UrlSegment(culture) == parts[0])
|
||||
: GetAtRoot(preview).FirstOrDefault(x => x.UrlSegment(culture) == parts[0]);
|
||||
content = FollowRoute(content, parts, 1, culture);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
while (content != null && i < parts.Count)
|
||||
{
|
||||
var part = parts[i++];
|
||||
content = content.Children.FirstOrDefault(x =>
|
||||
content = content.Children(culture).FirstOrDefault(x =>
|
||||
{
|
||||
var urlSegment = x.UrlSegment(culture);
|
||||
return urlSegment == part;
|
||||
|
||||
@@ -341,17 +341,18 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<IPublishedContent> Children
|
||||
public override IEnumerable<IPublishedContent> Children(string culture = null)
|
||||
{
|
||||
get
|
||||
{
|
||||
var cache = GetAppropriateCache();
|
||||
if (cache == null || PublishedSnapshotService.CachePublishedContentChildren == false)
|
||||
return GetChildren();
|
||||
// FIXME THIS CANNOT WORK
|
||||
// we cannot cache children this way, they should be a linked list!
|
||||
throw new NotImplementedException();
|
||||
|
||||
// note: ToArray is important here, we want to cache the result, not the function!
|
||||
return (IEnumerable<IPublishedContent>)cache.Get(ChildrenCacheKey, () => GetChildren().ToArray());
|
||||
}
|
||||
var cache = GetAppropriateCache();
|
||||
if (cache == null || PublishedSnapshotService.CachePublishedContentChildren == false)
|
||||
return GetChildren();
|
||||
|
||||
// note: ToArray is important here, we want to cache the result, not the function!
|
||||
return (IEnumerable<IPublishedContent>)cache.Get(ChildrenCacheKey, () => GetChildren().ToArray());
|
||||
}
|
||||
|
||||
private string _childrenCacheKey;
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Umbraco.Web.PublishedCache
|
||||
|
||||
public override IPublishedContent Parent() => null;
|
||||
|
||||
public override IEnumerable<IPublishedContent> Children => Enumerable.Empty<IPublishedContent>();
|
||||
public override IEnumerable<IPublishedContent> Children(string culture = null) => Enumerable.Empty<IPublishedContent>();
|
||||
|
||||
public override IEnumerable<IPublishedProperty> Properties => _properties;
|
||||
|
||||
|
||||
@@ -891,6 +891,7 @@ namespace Umbraco.Web
|
||||
|
||||
#region Axes: children
|
||||
|
||||
// FIXME: kill that one
|
||||
/// <summary>
|
||||
/// Gets the children of the content.
|
||||
/// </summary>
|
||||
@@ -905,7 +906,7 @@ namespace Umbraco.Web
|
||||
{
|
||||
if (content == null) throw new ArgumentNullException(nameof(content));
|
||||
|
||||
return content.Children.WhereIsInvariantOrHasCulture(culture);
|
||||
return content.Children(culture); //.WhereIsInvariantOrHasCulture(culture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1029,7 +1030,7 @@ namespace Umbraco.Web
|
||||
//create all row data
|
||||
var tableData = Core.DataTableExtensions.CreateTableData();
|
||||
//loop through each child and create row data for it
|
||||
foreach (var n in content.Children.OrderBy(x => x.SortOrder))
|
||||
foreach (var n in content.Children().OrderBy(x => x.SortOrder))
|
||||
{
|
||||
if (contentTypeAliasFilter.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user