diff --git a/uSync.BackOffice/Services/ISyncService.cs b/uSync.BackOffice/Services/ISyncService.cs index 84937fae..f24c36ee 100644 --- a/uSync.BackOffice/Services/ISyncService.cs +++ b/uSync.BackOffice/Services/ISyncService.cs @@ -3,6 +3,8 @@ using System.IO; using System.Threading.Tasks; +using Umbraco.Cms.Core; + using uSync.BackOffice.Configuration; using uSync.BackOffice.Models; using uSync.BackOffice.SyncHandlers.Interfaces; @@ -168,4 +170,12 @@ public interface ISyncService /// merge the given folders in single 'production' files for each handler. /// Task MergeExportFolder(string[] paths, IEnumerable handlers); + + /// + /// export a single item to the specified folders using the supplied handler options. + /// + /// The unique document identifier of the item to export. + /// The target folders to export the item into. + /// The handler options to use during export. + Task> ExportSingleItem(Udi udi, string[] folders, SyncHandlerOptions options); } \ No newline at end of file diff --git a/uSync.BackOffice/Services/SyncService_Single.cs b/uSync.BackOffice/Services/SyncService_Single.cs index 92e548c4..f9b0b341 100644 --- a/uSync.BackOffice/Services/SyncService_Single.cs +++ b/uSync.BackOffice/Services/SyncService_Single.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using System.Xml.Linq; +using Umbraco.Cms.Core; using Umbraco.Extensions; using uSync.BackOffice.Extensions; @@ -360,4 +361,18 @@ public async Task> LoadOrderedNodesAsync(ISyncHandler han /// private static int CalculateProgress(int value, int total, int min, int max) => (int)(min + (((float)value / total) * (max - min))); + + + /// + /// export a single item via the correct handler. + /// + /// + /// this method isn't used directly in the code, but is here as a helper . + /// + public async Task> ExportSingleItem(Udi udi, string[] folders, SyncHandlerOptions options) + { + var handler = _handlerFactory.GetValidHandlerByEntityType(udi.EntityType, options); + if (handler == null) return [uSyncAction.Fail("Single", "Unknown", udi.EntityType, ChangeType.Fail, $"Could not find handler for entity type '{udi.EntityType}'", new KeyNotFoundException(udi.EntityType))]; + return await handler.Handler.ExportAsync(udi, folders, handler.Settings); + } }