Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Hooks
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 1
 onSearchAfterNoDirectMatch
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2
3namespace MediaWiki\Extension\SearchExtraNS;
4
5use MediaWiki\Search\Hook\SearchAfterNoDirectMatchHook;
6use MediaWiki\Title\Title;
7
8class Hooks implements SearchAfterNoDirectMatchHook {
9
10    /**
11     * @param string $term
12     * @param Title &$title
13     * @return bool
14     */
15    public function onSearchAfterNoDirectMatch( $term, &$title ) {
16        global $wgSearchExtraNamespaces;
17
18        if ( !is_array( $wgSearchExtraNamespaces ) ) {
19            return true;
20        }
21
22        foreach ( $wgSearchExtraNamespaces as $ens ) {
23            $title = Title::newFromText( $term, $ens );
24            if ( $title && $title->exists() ) {
25                return false;
26            }
27        }
28
29        return true;
30    }
31}