From 9a0e85af10dbf1535f0929dfad4615af70556c4c Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 19 Jan 2016 21:38:11 +0100 Subject: [PATCH] Creates new CreateTemplateForContentType for use with the content type editor, I need to somehow add some additional information to the event raised there so that we can listen to that event in MB in order to create the default template markup. --- src/Umbraco.Core/Services/FileService.cs | 156 ++++++++++-------- src/Umbraco.Core/Services/IFileService.cs | 11 ++ src/Umbraco.Core/Services/ServiceContext.cs | 2 +- .../Editors/ContentTypeController.cs | 38 +++-- 4 files changed, 126 insertions(+), 81 deletions(-) diff --git a/src/Umbraco.Core/Services/FileService.cs b/src/Umbraco.Core/Services/FileService.cs index cbda2fce80..def10c0051 100644 --- a/src/Umbraco.Core/Services/FileService.cs +++ b/src/Umbraco.Core/Services/FileService.cs @@ -23,34 +23,22 @@ namespace Umbraco.Core.Services /// /// Represents the File Service, which is an easy access to operations involving objects like Scripts, Stylesheets and Templates /// - public class FileService : IFileService + public class FileService : RepositoryService, IFileService { - private readonly RepositoryFactory _repositoryFactory; private readonly IUnitOfWorkProvider _fileUowProvider; - private readonly IDatabaseUnitOfWorkProvider _dataUowProvider; private const string PartialViewHeader = "@inherits Umbraco.Web.Mvc.UmbracoTemplatePage"; private const string PartialViewMacroHeader = "@inherits Umbraco.Web.Macros.PartialViewMacroPage"; - [Obsolete("Use the constructors that specify all dependencies instead")] - public FileService() - : this(new RepositoryFactory()) - { } - - [Obsolete("Use the constructors that specify all dependencies instead")] - public FileService(RepositoryFactory repositoryFactory) - : this(new FileUnitOfWorkProvider(), new PetaPocoUnitOfWorkProvider(), repositoryFactory) + public FileService( + IUnitOfWorkProvider fileProvider, + IDatabaseUnitOfWorkProvider dataProvider, + RepositoryFactory repositoryFactory, + ILogger logger, + IEventMessagesFactory eventMessagesFactory) + : base(dataProvider, repositoryFactory, logger, eventMessagesFactory) { - } - - public FileService(IUnitOfWorkProvider fileProvider, IDatabaseUnitOfWorkProvider dataProvider, RepositoryFactory repositoryFactory) - { - if (fileProvider == null) throw new ArgumentNullException("fileProvider"); - if (dataProvider == null) throw new ArgumentNullException("dataProvider"); - if (repositoryFactory == null) throw new ArgumentNullException("repositoryFactory"); - _repositoryFactory = repositoryFactory; - _fileUowProvider = fileProvider; - _dataUowProvider = dataProvider; + _fileUowProvider = fileProvider; } @@ -62,7 +50,7 @@ namespace Umbraco.Core.Services /// An enumerable list of objects public IEnumerable GetStylesheets(params string[] names) { - using (var repository = _repositoryFactory.CreateStylesheetRepository(_fileUowProvider.GetUnitOfWork(), _dataUowProvider.GetUnitOfWork())) + using (var repository = RepositoryFactory.CreateStylesheetRepository(_fileUowProvider.GetUnitOfWork(), UowProvider.GetUnitOfWork())) { return repository.GetAll(names); } @@ -75,7 +63,7 @@ namespace Umbraco.Core.Services /// A object public Stylesheet GetStylesheetByName(string name) { - using (var repository = _repositoryFactory.CreateStylesheetRepository(_fileUowProvider.GetUnitOfWork(), _dataUowProvider.GetUnitOfWork())) + using (var repository = RepositoryFactory.CreateStylesheetRepository(_fileUowProvider.GetUnitOfWork(), UowProvider.GetUnitOfWork())) { return repository.Get(name); } @@ -92,7 +80,7 @@ namespace Umbraco.Core.Services return; var uow = _fileUowProvider.GetUnitOfWork(); - using (var repository = _repositoryFactory.CreateStylesheetRepository(uow, _dataUowProvider.GetUnitOfWork())) + using (var repository = RepositoryFactory.CreateStylesheetRepository(uow, UowProvider.GetUnitOfWork())) { repository.AddOrUpdate(stylesheet); uow.Commit(); @@ -111,7 +99,7 @@ namespace Umbraco.Core.Services public void DeleteStylesheet(string path, int userId = 0) { var uow = _fileUowProvider.GetUnitOfWork(); - using (var repository = _repositoryFactory.CreateStylesheetRepository(uow, _dataUowProvider.GetUnitOfWork())) + using (var repository = RepositoryFactory.CreateStylesheetRepository(uow, UowProvider.GetUnitOfWork())) { var stylesheet = repository.Get(path); if (stylesheet == null) return; @@ -137,7 +125,7 @@ namespace Umbraco.Core.Services { var uow = _fileUowProvider.GetUnitOfWork(); - using (var repository = _repositoryFactory.CreateStylesheetRepository(uow, _dataUowProvider.GetUnitOfWork())) + using (var repository = RepositoryFactory.CreateStylesheetRepository(uow, UowProvider.GetUnitOfWork())) { return repository.ValidateStylesheet(stylesheet); } @@ -152,7 +140,7 @@ namespace Umbraco.Core.Services /// An enumerable list of objects public IEnumerable