Changed Loader and Setter delegates of the LazyFields of LocalizationPart to (#8693)

use Store/Retrieve implementations rather than go directly to the Record.
This commit is contained in:
Matteo Piovanelli 2023-05-26 09:12:14 +02:00 committed by GitHub
parent 610b3c4f53
commit e55dbb0db8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,22 +31,26 @@ namespace Orchard.Localization.Handlers {
protected static void PropertySetHandlers(ActivatedContentContext context, LocalizationPart localizationPart) {
localizationPart.CultureField.Setter(cultureRecord => {
localizationPart.Record.CultureId = cultureRecord.Id;
localizationPart.Store<LocalizationPart, LocalizationPartRecord, int>(r => r.CultureId,
cultureRecord != null ? cultureRecord.Id : 0);
return cultureRecord;
});
localizationPart.MasterContentItemField.Setter(masterContentItem => {
localizationPart.Record.MasterContentItemId = masterContentItem.ContentItem.Id;
localizationPart.Store<LocalizationPart, LocalizationPartRecord, int>(r => r.MasterContentItemId,
masterContentItem.ContentItem.Id);
return masterContentItem;
});
});
}
protected void LazyLoadHandlers(LocalizationPart localizationPart) {
localizationPart.CultureField.Loader(() =>
_cultureManager.GetCultureById(localizationPart.Record.CultureId));
localizationPart.CultureField.Loader(() =>
_cultureManager.GetCultureById(
localizationPart.Retrieve<LocalizationPart, LocalizationPartRecord, int>(r => r.CultureId)));
localizationPart.MasterContentItemField.Loader(() =>
_contentManager.Get(localizationPart.Record.MasterContentItemId, VersionOptions.AllVersions));
_contentManager.Get(
localizationPart.Retrieve<LocalizationPart, LocalizationPartRecord, int>(r => r.MasterContentItemId), VersionOptions.AllVersions));
}
}
}