mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-55356 core_search: API to check if indexing enabled
New function \core_search\manager::is_indexing_enabled(), analagous to existing is_global_search_enabled(). This replaces existing duplicated code, ready for more use in following commits.
This commit is contained in:
parent
0da8f62f3b
commit
d761b3fb19
@ -46,8 +46,7 @@ class search_index_task extends scheduled_task {
|
||||
* Throw exceptions on errors (the job will be retried).
|
||||
*/
|
||||
public function execute() {
|
||||
if (!\core_search\manager::is_global_search_enabled() &&
|
||||
!get_config('core', 'searchindexwhendisabled')) {
|
||||
if (!\core_search\manager::is_indexing_enabled()) {
|
||||
return;
|
||||
}
|
||||
$globalsearch = \core_search\manager::instance();
|
||||
|
@ -49,8 +49,7 @@ class search_optimize_task extends scheduled_task {
|
||||
* Throw exceptions on errors (the job will be retried).
|
||||
*/
|
||||
public function execute() {
|
||||
if (!\core_search\manager::is_global_search_enabled() &&
|
||||
!get_config('core', 'searchindexwhendisabled')) {
|
||||
if (!\core_search\manager::is_indexing_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,17 @@ class manager {
|
||||
return !empty($CFG->enableglobalsearch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether indexing is enabled or not (you can enable indexing even when search is not
|
||||
* enabled at the moment, so as to have it ready for students).
|
||||
*
|
||||
* @return bool True if indexing is enabled.
|
||||
*/
|
||||
public static function is_indexing_enabled() {
|
||||
global $CFG;
|
||||
return !empty($CFG->enableglobalsearch) || !empty($CFG->searchindexwhendisabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of the search engine.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user