Merge branch 'temp8' of https://github.com/umbraco/Umbraco-CMS into temp8
This commit is contained in:
@@ -200,7 +200,7 @@ namespace Umbraco.Core.Services
|
||||
/// </returns>
|
||||
Attempt<OperationResult<OperationResultType, ITemplate>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = 0);
|
||||
|
||||
ITemplate CreateTemplateWithIdentity(string name, string content, ITemplate masterTemplate = null, int userId = 0);
|
||||
ITemplate CreateTemplateWithIdentity(string name, string alias, string content, ITemplate masterTemplate = null, int userId = 0);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a template by its alias
|
||||
|
||||
@@ -390,16 +390,17 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// Create a new template, setting the content if a view exists in the filesystem
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="alias"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="masterTemplate"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public ITemplate CreateTemplateWithIdentity(string name, string content, ITemplate masterTemplate = null, int userId = 0)
|
||||
public ITemplate CreateTemplateWithIdentity(string name, string alias, string content, ITemplate masterTemplate = null, int userId = 0)
|
||||
{
|
||||
// file might already be on disk, if so grab the content to avoid overwriting
|
||||
var template = new Template(name, name)
|
||||
var template = new Template(name, alias)
|
||||
{
|
||||
Content = GetViewContent(name) ?? content
|
||||
Content = GetViewContent(alias) ?? content
|
||||
};
|
||||
|
||||
if (masterTemplate != null)
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace Umbraco.Tests.Services
|
||||
[Test]
|
||||
public void Create_Template_Then_Assign_Child()
|
||||
{
|
||||
var child = ServiceContext.FileService.CreateTemplateWithIdentity("child", "test");
|
||||
var parent = ServiceContext.FileService.CreateTemplateWithIdentity("parent", "test");
|
||||
var child = ServiceContext.FileService.CreateTemplateWithIdentity("Child", "child", "test");
|
||||
var parent = ServiceContext.FileService.CreateTemplateWithIdentity("Parent", "parent", "test");
|
||||
|
||||
child.SetMasterTemplate(parent);
|
||||
ServiceContext.FileService.SaveTemplate(child);
|
||||
@@ -34,8 +34,8 @@ namespace Umbraco.Tests.Services
|
||||
[Test]
|
||||
public void Create_Template_With_Child_Then_Unassign()
|
||||
{
|
||||
var parent = ServiceContext.FileService.CreateTemplateWithIdentity("parent", "test");
|
||||
var child = ServiceContext.FileService.CreateTemplateWithIdentity("child", "test", parent);
|
||||
var parent = ServiceContext.FileService.CreateTemplateWithIdentity("Parent", "parent", "test");
|
||||
var child = ServiceContext.FileService.CreateTemplateWithIdentity("Child", "child", "test", parent);
|
||||
|
||||
child.SetMasterTemplate(null);
|
||||
ServiceContext.FileService.SaveTemplate(child);
|
||||
@@ -48,9 +48,9 @@ namespace Umbraco.Tests.Services
|
||||
[Test]
|
||||
public void Can_Query_Template_Children()
|
||||
{
|
||||
var parent = ServiceContext.FileService.CreateTemplateWithIdentity("parent", "test");
|
||||
var child1 = ServiceContext.FileService.CreateTemplateWithIdentity("child1", "test", parent);
|
||||
var child2 = ServiceContext.FileService.CreateTemplateWithIdentity("child2", "test", parent);
|
||||
var parent = ServiceContext.FileService.CreateTemplateWithIdentity("Parent", "parent", "test");
|
||||
var child1 = ServiceContext.FileService.CreateTemplateWithIdentity("Child1", "child1", "test", parent);
|
||||
var child2 = ServiceContext.FileService.CreateTemplateWithIdentity("Child2", "child2", "test", parent);
|
||||
|
||||
var children = ServiceContext.FileService.GetTemplates(parent.Id).Select(x => x.Id).ToArray();
|
||||
|
||||
@@ -58,5 +58,18 @@ namespace Umbraco.Tests.Services
|
||||
Assert.IsTrue(children.Contains(child2.Id));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Create_Template_With_Custom_Alias()
|
||||
{
|
||||
var template = ServiceContext.FileService.CreateTemplateWithIdentity("Test template", "customTemplateAlias", "test");
|
||||
|
||||
ServiceContext.FileService.SaveTemplate(template);
|
||||
|
||||
template = ServiceContext.FileService.GetTemplate(template.Id);
|
||||
|
||||
Assert.AreEqual("Test template", template.Name);
|
||||
Assert.AreEqual("customTemplateAlias", template.Alias);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
var template = Services.FileService.CreateTemplateWithIdentity(display.Alias, display.Content, master);
|
||||
var template = Services.FileService.CreateTemplateWithIdentity(display.Name, display.Alias, display.Content, master);
|
||||
Mapper.Map(template, display);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user