18 private const GROUPS =
'groups';
19 private const MESSAGES =
'messages';
21 public function __construct(
26 parent::__construct( $mainModule, $moduleName );
27 $this->entitySearch = $entitySearch;
30 public function execute() {
31 $query = $this->getParameter(
'query' );
32 $maxResults = $this->getParameter(
'limit' );
33 $entityTypes = $this->getParameter(
'entitytype' );
34 $groupTypeFilter = $this->getParameter(
'grouptypes' );
37 $remainingResults = $maxResults;
39 if ( in_array( self::GROUPS, $entityTypes ) ) {
40 $searchResults[ self::GROUPS ] = $this->entitySearch
41 ->searchStaticMessageGroups( $query, $maxResults, $groupTypeFilter );
42 $remainingResults = $maxResults - count( $searchResults[ self::GROUPS ] );
45 if ( in_array( self::MESSAGES, $entityTypes ) && $remainingResults > 0 ) {
46 $searchResults[ self::MESSAGES ] = $this->entitySearch
47 ->searchMessages( $query, $remainingResults );
50 $this->getResult()->addValue(
null, $this->getModuleName(), $searchResults );
53 protected function getAllowedParams(): array {
56 ParamValidator::PARAM_TYPE => [ self::GROUPS, self::MESSAGES ],
57 ParamValidator::PARAM_ISMULTI =>
true,
58 ParamValidator::PARAM_DEFAULT => implode(
'|', [ self::GROUPS, self::MESSAGES ] )
61 ParamValidator::PARAM_TYPE =>
'string',
62 ParamValidator::PARAM_DEFAULT =>
''
65 ParamValidator::PARAM_TYPE =>
'limit',
66 ParamValidator::PARAM_DEFAULT => 10,
67 NumericDef::PARAM_MAX => ApiBase::LIMIT_SML1
70 ParamValidator::PARAM_ISMULTI =>
true,
71 ParamValidator::PARAM_DEFAULT => [],
72 ParamValidator::PARAM_TYPE => array_keys( $this->entitySearch->getGroupTypes() )
77 public function isInternal():
bool {