Gets trees and sections loading now in a much more simplified way without any xml, now to cleanup
This commit is contained in:
@@ -1,153 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Web.Services
|
||||
{
|
||||
public interface IApplicationTreeService
|
||||
{
|
||||
///// <summary>
|
||||
///// Creates a new application tree.
|
||||
///// </summary>
|
||||
///// <param name="initialize">if set to <c>true</c> [initialize].</param>
|
||||
///// <param name="sortOrder">The sort order.</param>
|
||||
///// <param name="applicationAlias">The application alias.</param>
|
||||
///// <param name="alias">The alias.</param>
|
||||
///// <param name="title">The title.</param>
|
||||
///// <param name="iconClosed">The icon closed.</param>
|
||||
///// <param name="iconOpened">The icon opened.</param>
|
||||
///// <param name="type">The type.</param>
|
||||
//void MakeNew(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type);
|
||||
|
||||
///// <summary>
|
||||
///// Saves this instance.
|
||||
///// </summary>
|
||||
//void SaveTree(ApplicationTree tree);
|
||||
|
||||
///// <summary>
|
||||
///// Deletes this instance.
|
||||
///// </summary>
|
||||
//void DeleteTree(ApplicationTree tree);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an ApplicationTree by it's tree alias.
|
||||
/// </summary>
|
||||
/// <param name="treeAlias">The tree alias.</param>
|
||||
/// <returns>An ApplicationTree instance</returns>
|
||||
ApplicationTree GetByAlias(string treeAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all applicationTrees registered in umbraco from the umbracoAppTree table..
|
||||
/// </summary>
|
||||
/// <returns>Returns a ApplicationTree Array</returns>
|
||||
IEnumerable<ApplicationTree> GetAll();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application tree for the applcation with the specified alias
|
||||
/// </summary>
|
||||
/// <param name="applicationAlias">The application alias.</param>
|
||||
/// <returns>Returns a ApplicationTree Array</returns>
|
||||
IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias);
|
||||
|
||||
///// <summary>
|
||||
///// Gets the application tree for the applcation with the specified alias
|
||||
///// </summary>
|
||||
///// <param name="applicationAlias">The application alias.</param>
|
||||
///// <param name="onlyInitialized"></param>
|
||||
///// <returns>Returns a ApplicationTree Array</returns>
|
||||
//IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias, bool onlyInitialized);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the grouped application trees for the application with the specified alias
|
||||
/// </summary>
|
||||
/// <param name="applicationAlias"></param>
|
||||
/// <returns></returns>
|
||||
IDictionary<string, IEnumerable<ApplicationTree>> GetGroupedApplicationTrees(string applicationAlias);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Purely used to allow a service context to create the default services
|
||||
/// </summary>
|
||||
internal class EmptyApplicationTreeService : IApplicationTreeService
|
||||
{
|
||||
///// <summary>
|
||||
///// Creates a new application tree.
|
||||
///// </summary>
|
||||
///// <param name="initialize">if set to <c>true</c> [initialize].</param>
|
||||
///// <param name="sortOrder">The sort order.</param>
|
||||
///// <param name="applicationAlias">The application alias.</param>
|
||||
///// <param name="alias">The alias.</param>
|
||||
///// <param name="title">The title.</param>
|
||||
///// <param name="iconClosed">The icon closed.</param>
|
||||
///// <param name="iconOpened">The icon opened.</param>
|
||||
///// <param name="type">The type.</param>
|
||||
//public void MakeNew(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type)
|
||||
//{
|
||||
// throw new System.NotImplementedException();
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Saves this instance.
|
||||
///// </summary>
|
||||
//public void SaveTree(ApplicationTree tree)
|
||||
//{
|
||||
// throw new System.NotImplementedException();
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Deletes this instance.
|
||||
///// </summary>
|
||||
//public void DeleteTree(ApplicationTree tree)
|
||||
//{
|
||||
// throw new System.NotImplementedException();
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an ApplicationTree by it's tree alias.
|
||||
/// </summary>
|
||||
/// <param name="treeAlias">The tree alias.</param>
|
||||
/// <returns>An ApplicationTree instance</returns>
|
||||
public ApplicationTree GetByAlias(string treeAlias)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all applicationTrees registered in umbraco from the umbracoAppTree table..
|
||||
/// </summary>
|
||||
/// <returns>Returns a ApplicationTree Array</returns>
|
||||
public IEnumerable<ApplicationTree> GetAll()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public IDictionary<string, IEnumerable<ApplicationTree>> GetGroupedApplicationTrees(string applicationAlias)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application tree for the applcation with the specified alias
|
||||
/// </summary>
|
||||
/// <param name="applicationAlias">The application alias.</param>
|
||||
/// <returns>Returns a ApplicationTree Array</returns>
|
||||
public IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application tree for the applcation with the specified alias
|
||||
/// </summary>
|
||||
/// <param name="applicationAlias">The application alias.</param>
|
||||
/// <param name="onlyInitialized"></param>
|
||||
/// <returns>Returns a ApplicationTree Array</returns>
|
||||
public IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias, bool onlyInitialized)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,92 +25,7 @@ namespace Umbraco.Web.Services
|
||||
/// <param name="appAlias">The application alias.</param>
|
||||
/// <returns></returns>
|
||||
IBackOfficeSection GetByAlias(string appAlias);
|
||||
|
||||
///// <summary>
|
||||
///// Creates a new applcation if no application with the specified alias is found.
|
||||
///// </summary>
|
||||
///// <param name="name">The application name.</param>
|
||||
///// <param name="alias">The application alias.</param>
|
||||
///// <param name="icon">The application icon, which has to be located in umbraco/images/tray folder.</param>
|
||||
//void MakeNew(string name, string alias, string icon);
|
||||
|
||||
///// <summary>
|
||||
///// Makes the new.
|
||||
///// </summary>
|
||||
///// <param name="name">The name.</param>
|
||||
///// <param name="alias">The alias.</param>
|
||||
///// <param name="icon">The icon.</param>
|
||||
///// <param name="sortOrder">The sort order.</param>
|
||||
//void MakeNew(string name, string alias, string icon, int sortOrder);
|
||||
|
||||
///// <summary>
|
||||
///// Deletes the section
|
||||
///// </summary>
|
||||
//void DeleteSection(Section section);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Purely used to allow a service context to create the default services
|
||||
/// </summary>
|
||||
internal class EmptySectionService : ISectionService
|
||||
{
|
||||
/// <summary>
|
||||
/// The cache storage for all applications
|
||||
/// </summary>
|
||||
public IEnumerable<IBackOfficeSection> GetSections()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the user's allowed sections
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<IBackOfficeSection> GetAllowedSections(int userId)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application by its alias.
|
||||
/// </summary>
|
||||
/// <param name="appAlias">The application alias.</param>
|
||||
/// <returns></returns>
|
||||
public IBackOfficeSection GetByAlias(string appAlias)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Creates a new applcation if no application with the specified alias is found.
|
||||
///// </summary>
|
||||
///// <param name="name">The application name.</param>
|
||||
///// <param name="alias">The application alias.</param>
|
||||
///// <param name="icon">The application icon, which has to be located in umbraco/images/tray folder.</param>
|
||||
//public void MakeNew(string name, string alias, string icon)
|
||||
//{
|
||||
// throw new System.NotImplementedException();
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Makes the new.
|
||||
///// </summary>
|
||||
///// <param name="name">The name.</param>
|
||||
///// <param name="alias">The alias.</param>
|
||||
///// <param name="icon">The icon.</param>
|
||||
///// <param name="sortOrder">The sort order.</param>
|
||||
//public void MakeNew(string name, string alias, string icon, int sortOrder)
|
||||
//{
|
||||
// throw new System.NotImplementedException();
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Deletes the section
|
||||
///// </summary>
|
||||
//public void DeleteSection(IBackOfficeSection section)
|
||||
//{
|
||||
// throw new System.NotImplementedException();
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
49
src/Umbraco.Web/Services/ITreeService.cs
Normal file
49
src/Umbraco.Web/Services/ITreeService.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Trees;
|
||||
|
||||
namespace Umbraco.Web.Services
|
||||
{
|
||||
public interface ITreeService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an ApplicationTree by it's tree alias.
|
||||
/// </summary>
|
||||
/// <param name="treeAlias">The tree alias.</param>
|
||||
/// <returns>An ApplicationTree instance</returns>
|
||||
ApplicationTree GetByAlias(string treeAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all applicationTrees registered in umbraco from the umbracoAppTree table..
|
||||
/// </summary>
|
||||
/// <returns>Returns a ApplicationTree Array</returns>
|
||||
IEnumerable<ApplicationTree> GetAll();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application tree for the applcation with the specified alias
|
||||
/// </summary>
|
||||
/// <param name="applicationAlias">The application alias.</param>
|
||||
/// <returns>Returns a ApplicationTree Array</returns>
|
||||
IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias);
|
||||
|
||||
///// <summary>
|
||||
///// Gets the application tree for the applcation with the specified alias
|
||||
///// </summary>
|
||||
///// <param name="applicationAlias">The application alias.</param>
|
||||
///// <param name="onlyInitialized"></param>
|
||||
///// <returns>Returns a ApplicationTree Array</returns>
|
||||
//IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias, bool onlyInitialized);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the grouped application trees for the application with the specified alias
|
||||
/// </summary>
|
||||
/// <param name="applicationAlias"></param>
|
||||
/// <returns></returns>
|
||||
IDictionary<string, IEnumerable<ApplicationTree>> GetGroupedApplicationTrees(string applicationAlias);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,18 +18,18 @@ using Umbraco.Web.Trees;
|
||||
|
||||
namespace Umbraco.Web.Services
|
||||
{
|
||||
internal class ApplicationTreeService : IApplicationTreeService
|
||||
internal class TreeService : ITreeService
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly TreeCollection _treeCollection;
|
||||
private static readonly object Locker = new object();
|
||||
private readonly Lazy<IReadOnlyCollection<IGrouping<string, string>>> _groupedTrees;
|
||||
|
||||
public ApplicationTreeService(ILogger logger, TreeCollection treeCollection)
|
||||
public TreeService(ILogger logger, TreeCollection treeCollection)
|
||||
{
|
||||
_logger = logger;
|
||||
_treeCollection = treeCollection;
|
||||
//_groupedTrees = new Lazy<IReadOnlyCollection<IGrouping<string, string>>>(InitGroupedTrees);
|
||||
_groupedTrees = new Lazy<IReadOnlyCollection<IGrouping<string, string>>>(InitGroupedTrees);
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
@@ -233,7 +233,7 @@ namespace Umbraco.Web.Services
|
||||
//}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ApplicationTree GetByAlias(string treeAlias) => _treeCollection.FirstOrDefault(t => t.Alias == treeAlias);
|
||||
public ApplicationTree GetByAlias(string treeAlias) => _treeCollection.FirstOrDefault(t => t.TreeAlias == treeAlias);
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ApplicationTree> GetAll() => _treeCollection;
|
||||
@@ -273,7 +273,7 @@ namespace Umbraco.Web.Services
|
||||
{
|
||||
foreach(var treeAliasInGroup in treeGroup)
|
||||
{
|
||||
if (tree.Alias == treeAliasInGroup)
|
||||
if (tree.TreeAlias == treeAliasInGroup)
|
||||
{
|
||||
if (resultGroup == null) resultGroup = new List<ApplicationTree>();
|
||||
resultGroup.Add(tree);
|
||||
@@ -286,21 +286,21 @@ namespace Umbraco.Web.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Creates a group of all tree groups and their tree aliases
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
///// <remarks>
|
||||
///// Used to initialize the <see cref="_groupedTrees"/> field
|
||||
///// </remarks>
|
||||
//private IReadOnlyCollection<IGrouping<string, string>> InitGroupedTrees()
|
||||
//{
|
||||
// var result = GetAll()
|
||||
// .Select(x => (treeAlias: x.Alias, treeGroup: x.GetRuntimeType().GetCustomAttribute<CoreTreeAttribute>(false)?.TreeGroup))
|
||||
// .GroupBy(x => x.treeGroup, x => x.treeAlias)
|
||||
// .ToList();
|
||||
// return result;
|
||||
//}
|
||||
/// <summary>
|
||||
/// Creates a group of all tree groups and their tree aliases
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Used to initialize the <see cref="_groupedTrees"/> field
|
||||
/// </remarks>
|
||||
private IReadOnlyCollection<IGrouping<string, string>> InitGroupedTrees()
|
||||
{
|
||||
var result = GetAll()
|
||||
.Select(x => (treeAlias: x.TreeAlias, treeGroup: x.TreeControllerType.GetCustomAttribute<CoreTreeAttribute>(false)?.TreeGroup))
|
||||
.GroupBy(x => x.treeGroup, x => x.treeAlias)
|
||||
.ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Loads in the xml structure from disk if one is found, otherwise loads in an empty xml structure, calls the
|
||||
Reference in New Issue
Block a user