From ae8a31855081aa5ec57b7f563f3a52453071098c Mon Sep 17 00:00:00 2001 From: yv01p Date: Tue, 23 Dec 2025 03:32:00 +0000 Subject: [PATCH] refactor(core): add VersionOperationService property to ContentService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of ContentService refactoring Phase 3. Adds constructor parameter and property for version operations delegation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/Umbraco.Core/Services/ContentService.cs | 30 ++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 176fd693c7..6371353922 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -55,6 +55,10 @@ public class ContentService : RepositoryService, IContentService private readonly IContentQueryOperationService? _queryOperationService; private readonly Lazy? _queryOperationServiceLazy; + // Version operation service fields (for Phase 3 extracted version operations) + private readonly IContentVersionOperationService? _versionOperationService; + private readonly Lazy? _versionOperationServiceLazy; + /// /// Gets the query operation service. /// @@ -63,6 +67,14 @@ public class ContentService : RepositoryService, IContentService _queryOperationService ?? _queryOperationServiceLazy?.Value ?? throw new InvalidOperationException("QueryOperationService not initialized. Ensure the service is properly injected via constructor."); + /// + /// Gets the version operation service. + /// + /// Thrown if the service was not properly initialized. + private IContentVersionOperationService VersionOperationService => + _versionOperationService ?? _versionOperationServiceLazy?.Value + ?? throw new InvalidOperationException("VersionOperationService not initialized. Ensure the service is properly injected via constructor."); + #region Constructors [Microsoft.Extensions.DependencyInjection.ActivatorUtilitiesConstructor] @@ -85,7 +97,8 @@ public class ContentService : RepositoryService, IContentService IOptionsMonitor optionsMonitor, IRelationService relationService, IContentCrudService crudService, - IContentQueryOperationService queryOperationService) // NEW PARAMETER - Phase 2 query operations + IContentQueryOperationService queryOperationService, // NEW PARAMETER - Phase 2 query operations + IContentVersionOperationService versionOperationService) // NEW PARAMETER - Phase 3 version operations : base(provider, loggerFactory, eventMessagesFactory) { _documentRepository = documentRepository; @@ -115,6 +128,11 @@ public class ContentService : RepositoryService, IContentService ArgumentNullException.ThrowIfNull(queryOperationService); _queryOperationService = queryOperationService; _queryOperationServiceLazy = null; // Not needed when directly injected + + // Phase 3: Version operation service (direct injection) + ArgumentNullException.ThrowIfNull(versionOperationService); + _versionOperationService = versionOperationService; + _versionOperationServiceLazy = null; // Not needed when directly injected } [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")] @@ -171,6 +189,11 @@ public class ContentService : RepositoryService, IContentService _queryOperationServiceLazy = new Lazy(() => StaticServiceProvider.Instance.GetRequiredService(), LazyThreadSafetyMode.ExecutionAndPublication); + + // Phase 3: Lazy resolution of IContentVersionOperationService + _versionOperationServiceLazy = new Lazy(() => + StaticServiceProvider.Instance.GetRequiredService(), + LazyThreadSafetyMode.ExecutionAndPublication); } [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")] @@ -226,6 +249,11 @@ public class ContentService : RepositoryService, IContentService _queryOperationServiceLazy = new Lazy(() => StaticServiceProvider.Instance.GetRequiredService(), LazyThreadSafetyMode.ExecutionAndPublication); + + // Phase 3: Lazy resolution of IContentVersionOperationService + _versionOperationServiceLazy = new Lazy(() => + StaticServiceProvider.Instance.GetRequiredService(), + LazyThreadSafetyMode.ExecutionAndPublication); } #endregion