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 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
CirrusSearchHookRunner
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 8
72
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onCirrusSearchRegisterFullTextQueryClassifiers
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onCirrusSearchAddQueryFeatures
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onCirrusSearchSimilarityConfig
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onCirrusSearchAnalysisConfig
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onCirrusSearchMappingConfig
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onCirrusSearchProfileService
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onCirrusSearchScoreBuilder
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace CirrusSearch;
4
5use CirrusSearch\Maintenance\AnalysisConfigBuilder;
6use CirrusSearch\Maintenance\MappingConfigBuilder;
7use CirrusSearch\Query\SimpleKeywordFeature;
8use CirrusSearch\Search\Rescore\BoostFunctionBuilder;
9use MediaWiki\HookContainer\HookContainer;
10
11/**
12 * @internal
13 */
14class CirrusSearchHookRunner {
15    /**
16     * @var HookContainer
17     */
18    private $hookContainer;
19
20    public function __construct( HookContainer $hookContainer ) {
21        $this->hookContainer = $hookContainer;
22    }
23
24    /**
25     * Register FullText query classifiers
26     * @param Parser\ParsedQueryClassifiersRepository $repository
27     */
28    public function onCirrusSearchRegisterFullTextQueryClassifiers( Parser\ParsedQueryClassifiersRepository $repository ): void {
29        $this->hookContainer->run( 'CirrusSearchRegisterFullTextQueryClassifiers', [ $repository ] );
30    }
31
32    /**
33     * Register new search keywords
34     * @param SearchConfig $config
35     * @param SimpleKeywordFeature[] &$extraFeatures
36     */
37    public function onCirrusSearchAddQueryFeatures( SearchConfig $config, array &$extraFeatures ): void {
38        $this->hookContainer->run( 'CirrusSearchAddQueryFeatures', [ $config, &$extraFeatures ] );
39    }
40
41    /**
42     * Register new similarity configurations
43     *
44     * @param array &$similarityConfig
45     */
46    public function onCirrusSearchSimilarityConfig( array &$similarityConfig ): void {
47        $this->hookContainer->run( 'CirrusSearchSimilarityConfig', [ &$similarityConfig ] );
48    }
49
50    /**
51     * Alter the analysis configuration
52     *
53     * @param array &$config
54     * @param AnalysisConfigBuilder $analyisConfigBuilder
55     */
56    public function onCirrusSearchAnalysisConfig( array &$config, AnalysisConfigBuilder $analyisConfigBuilder ): void {
57        $this->hookContainer->run( 'CirrusSearchAnalysisConfig', [ &$config, $analyisConfigBuilder ] );
58    }
59
60    /**
61     * Alter the mapping configuration
62     *
63     * @param array &$mappingConfig
64     * @param MappingConfigBuilder $mappingConfigBuilder
65     */
66    public function onCirrusSearchMappingConfig( array &$mappingConfig, MappingConfigBuilder $mappingConfigBuilder ): void {
67        $this->hookContainer->run( 'CirrusSearchMappingConfig', [ &$mappingConfig, $mappingConfigBuilder ] );
68    }
69
70    /**
71     * Register search profiles
72     *
73     * @param Profile\SearchProfileService $service
74     */
75    public function onCirrusSearchProfileService( Profile\SearchProfileService $service ): void {
76        $this->hookContainer->run( 'CirrusSearchProfileService', [ $service ] );
77    }
78
79    /**
80     * @param array $definition
81     * @param Search\SearchContext $context
82     * @param BoostFunctionBuilder|null &$builder
83     */
84    public function onCirrusSearchScoreBuilder( array $definition, Search\SearchContext $context, ?BoostFunctionBuilder &$builder ): void {
85        $this->hookContainer->run( 'CirrusSearchScoreBuilder', [ $definition, $context, &$builder ] );
86    }
87}