Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\search\Plugin;
|
Chris@0
|
4
|
Chris@0
|
5 /**
|
Chris@0
|
6 * Defines an optional interface for SearchPlugin objects using an index.
|
Chris@0
|
7 *
|
Chris@0
|
8 * Plugins implementing this interface will have these methods invoked during
|
Chris@0
|
9 * search_cron() and via the search module administration form. Plugins not
|
Chris@0
|
10 * implementing this interface are assumed to be using their own methods for
|
Chris@0
|
11 * searching, not involving separate index tables.
|
Chris@0
|
12 *
|
Chris@0
|
13 * The user interface for managing search pages displays the indexing status for
|
Chris@0
|
14 * search pages implementing this interface. It also allows users to configure
|
Chris@0
|
15 * default settings for indexing, and refers to the "default search index". If
|
Chris@0
|
16 * your search page plugin uses its own indexing mechanism instead of the
|
Chris@0
|
17 * default search index, or overrides the default indexing settings, you should
|
Chris@0
|
18 * make this clear on the settings page or other documentation for your plugin.
|
Chris@0
|
19 *
|
Chris@0
|
20 * Multiple search pages can be created for each search plugin, so you will need
|
Chris@0
|
21 * to choose whether these search pages should share an index (in which case
|
Chris@0
|
22 * they must not use any search page-specific configuration while indexing) or
|
Chris@0
|
23 * they will have separate indexes (which will use additional server resources).
|
Chris@0
|
24 */
|
Chris@0
|
25 interface SearchIndexingInterface {
|
Chris@0
|
26
|
Chris@0
|
27 /**
|
Chris@0
|
28 * Updates the search index for this plugin.
|
Chris@0
|
29 *
|
Chris@0
|
30 * This method is called every cron run if the plugin has been set as
|
Chris@0
|
31 * an active search module on the Search settings page
|
Chris@0
|
32 * (admin/config/search/pages). It allows your module to add items to the
|
Chris@0
|
33 * built-in search index using search_index(), or to add them to your module's
|
Chris@0
|
34 * own indexing mechanism.
|
Chris@0
|
35 *
|
Chris@0
|
36 * When implementing this method, your module should index content items that
|
Chris@0
|
37 * were modified or added since the last run. There is a time limit for cron,
|
Chris@0
|
38 * so it is advisable to limit how many items you index per run using
|
Chris@0
|
39 * config('search.settings')->get('index.cron_limit') or with your own
|
Chris@0
|
40 * setting. And since the cron run could time out and abort in the middle of
|
Chris@0
|
41 * your run, you should update any needed internal bookkeeping on when items
|
Chris@0
|
42 * have last been indexed as you go rather than waiting to the end of
|
Chris@0
|
43 * indexing.
|
Chris@0
|
44 */
|
Chris@0
|
45 public function updateIndex();
|
Chris@0
|
46
|
Chris@0
|
47 /**
|
Chris@0
|
48 * Clears the search index for this plugin.
|
Chris@0
|
49 *
|
Chris@0
|
50 * When a request is made to clear all items from the search index related to
|
Chris@0
|
51 * this plugin, this method will be called. If this plugin uses the default
|
Chris@0
|
52 * search index, this method can call search_index_clear($type) to remove
|
Chris@0
|
53 * indexed items from the search database.
|
Chris@0
|
54 *
|
Chris@0
|
55 * @see search_index_clear()
|
Chris@0
|
56 */
|
Chris@0
|
57 public function indexClear();
|
Chris@0
|
58
|
Chris@0
|
59 /**
|
Chris@0
|
60 * Marks the search index for reindexing for this plugin.
|
Chris@0
|
61 *
|
Chris@0
|
62 * When a request is made to mark all items from the search index related to
|
Chris@0
|
63 * this plugin for reindexing, this method will be called. If this plugin uses
|
Chris@0
|
64 * the default search index, this method can call
|
Chris@0
|
65 * search_mark_for_reindex($type) to mark the items in the search database for
|
Chris@0
|
66 * reindexing.
|
Chris@0
|
67 *
|
Chris@0
|
68 * @see search_mark_for_reindex()
|
Chris@0
|
69 */
|
Chris@0
|
70 public function markForReindex();
|
Chris@0
|
71
|
Chris@0
|
72 /**
|
Chris@0
|
73 * Reports the status of indexing.
|
Chris@0
|
74 *
|
Chris@0
|
75 * The core search module only invokes this method on active module plugins.
|
Chris@0
|
76 * Implementing modules do not need to check whether they are active when
|
Chris@0
|
77 * calculating their return values.
|
Chris@0
|
78 *
|
Chris@0
|
79 * @return array
|
Chris@0
|
80 * An associative array with the key-value pairs:
|
Chris@0
|
81 * - remaining: The number of items left to index.
|
Chris@0
|
82 * - total: The total number of items to index.
|
Chris@0
|
83 */
|
Chris@0
|
84 public function indexStatus();
|
Chris@0
|
85
|
Chris@0
|
86 }
|