mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
When a content item is modified the indexing events are fired
--HG-- branch : dev
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Tasks.Indexing;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Indexing.Handlers {
|
||||
/// <summary>
|
||||
@@ -9,9 +10,14 @@ namespace Orchard.Indexing.Handlers {
|
||||
/// is published, and to delete them when the content item is unpublished.
|
||||
/// </summary>
|
||||
public class CreateIndexingTaskHandler : ContentHandler {
|
||||
private const string SearchIndexName = "Search";
|
||||
private readonly IIndexingTaskManager _indexingTaskManager;
|
||||
private readonly IEnumerable<IIndexNotifierHandler> _indexNotifierHandlers;
|
||||
|
||||
public CreateIndexingTaskHandler(IIndexingTaskManager indexingTaskManager) {
|
||||
public CreateIndexingTaskHandler(
|
||||
IIndexingTaskManager indexingTaskManager,
|
||||
IEnumerable<IIndexNotifierHandler> indexNotifierHandlers
|
||||
) {
|
||||
_indexingTaskManager = indexingTaskManager;
|
||||
|
||||
OnPublishing<ContentPart<CommonPartRecord>>(CreateIndexingTask);
|
||||
@@ -26,5 +32,10 @@ namespace Orchard.Indexing.Handlers {
|
||||
_indexingTaskManager.CreateDeleteIndexTask(context.ContentItem);
|
||||
}
|
||||
|
||||
private void UpdateIndex() {
|
||||
foreach (var handler in _indexNotifierHandlers) {
|
||||
handler.UpdateIndex(SearchIndexName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user