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