Netcore: Migrate RepositoryBase and ContentTypeServiceBase events (#10141)
* Remove ScopeEntityRemove from ContentRepositoryBase and rely on "ing" notifications * Remove old event handler from ContentEventsTests * Remove ScopedVersionRemove from ContentRepositoryBase and rely on service notifications instead * Remove unused ScopedVersionEventArgs from ContentRepositoryBase * Migrate ScopeEntityRefresh to notification pattern Unfortunately it's still published from the repository base * Add simple content type notifications * Publish Notifications instead of events in ContentTypeServiceBase for simple events * Switch OnChanged to use Notifications for ContentTypeServices * Publish notifications instead of raising ScopedRefreshedEntity on ContentTypeServiceBase * Hook up to the new ContentType notifications * Remove DistributedCacheBinderTests There are no longer any events to really test on. * Remove ContentTypeChange EventArgs * Remove ContentService_Copied from DistributedCacheBinder It's no longer used * Cleanup * Cleanup * Removed uncommented code * Fixed issue with unattented installs * Re-add ContentTreeChangeNotification to DistributedCache * Add new notification for ScopedEntityRemove Marked as obsolete/hidden in editor, since this should only be used for nucache for now, and should really be changed in the future * Mark Refresh notifications as obsolete/hidden These should not be used anywhere outside Nucache, and should be changed to tree change at some point. * Raise ScopedEntityRemoveNotification on repos and use in nucache Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text.RegularExpressions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NPoco;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Persistence;
|
||||
using Umbraco.Cms.Core.Persistence.Querying;
|
||||
@@ -46,8 +47,9 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
MediaUrlGeneratorCollection mediaUrlGenerators,
|
||||
DataValueReferenceFactoryCollection dataValueReferenceFactories,
|
||||
IDataTypeService dataTypeService,
|
||||
IJsonSerializer serializer)
|
||||
: base(scopeAccessor, cache, logger, languageRepository, relationRepository, relationTypeRepository, propertyEditorCollection, dataValueReferenceFactories, dataTypeService)
|
||||
IJsonSerializer serializer,
|
||||
IEventAggregator eventAggregator)
|
||||
: base(scopeAccessor, cache, logger, languageRepository, relationRepository, relationTypeRepository, propertyEditorCollection, dataValueReferenceFactories, dataTypeService, eventAggregator)
|
||||
{
|
||||
_mediaTypeRepository = mediaTypeRepository ?? throw new ArgumentNullException(nameof(mediaTypeRepository));
|
||||
_tagRepository = tagRepository ?? throw new ArgumentNullException(nameof(tagRepository));
|
||||
@@ -225,9 +227,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
|
||||
protected override void PerformDeleteVersion(int id, int versionId)
|
||||
{
|
||||
// raise event first else potential FK issues
|
||||
OnUowRemovingVersion(new ScopedVersionEventArgs(AmbientScope, id, versionId));
|
||||
|
||||
Database.Delete<PropertyDataDto>("WHERE versionId = @versionId", new { versionId });
|
||||
Database.Delete<ContentVersionDto>("WHERE versionId = @versionId", new { versionId });
|
||||
}
|
||||
@@ -307,7 +306,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
|
||||
PersistRelations(entity);
|
||||
|
||||
OnUowRefreshedEntity(new ScopedEntityEventArgs(AmbientScope, entity));
|
||||
OnUowRefreshedEntity(new MediaRefreshNotification(entity, new EventMessages()));
|
||||
|
||||
entity.ResetDirtyProperties();
|
||||
}
|
||||
@@ -370,15 +369,15 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
PersistRelations(entity);
|
||||
}
|
||||
|
||||
OnUowRefreshedEntity(new ScopedEntityEventArgs(AmbientScope, entity));
|
||||
OnUowRefreshedEntity(new MediaRefreshNotification(entity, new EventMessages()));
|
||||
|
||||
entity.ResetDirtyProperties();
|
||||
}
|
||||
|
||||
protected override void PersistDeletedItem(IMedia entity)
|
||||
{
|
||||
// raise event first else potential FK issues
|
||||
OnUowRemovingEntity(new ScopedEntityEventArgs(AmbientScope, entity));
|
||||
// Raise event first else potential FK issues
|
||||
OnUowRemovingEntity(entity);
|
||||
base.PersistDeletedItem(entity);
|
||||
}
|
||||
|
||||
@@ -407,10 +406,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
return _mediaByGuidReadRepository.Exists(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// A reading repository purely for looking up by GUID
|
||||
// TODO: This is ugly and to fix we need to decouple the IRepositoryQueryable -> IRepository -> IReadRepository which should all be separate things!
|
||||
// This sub-repository pattern is super old and totally unecessary anymore, caching can be handled in much nicer ways without this
|
||||
// This sub-repository pattern is super old and totally unecessary anymore, caching can be handled in much nicer ways without this
|
||||
private class MediaByGuidReadRepository : EntityRepositoryBase<Guid, IMedia>
|
||||
{
|
||||
private readonly MediaRepository _outerRepo;
|
||||
|
||||
Reference in New Issue
Block a user