Page MenuHomeWickedGov Phorge

WikibaseEntitySelector.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

WikibaseEntitySelector.php

<?php
namespace MediaWiki\Extension\Math\Widget;
use MediaWiki\Logger\LoggerFactory;
use OOUI\SearchInputWidget;
class WikibaseEntitySelector extends SearchInputWidget {
/** @var string */
protected $paramType = 'item';
// This should be \Wikimedia\ParamValidator\ParamValidator::PARAM_TYPE of the target API
private const ALLOWED_TYPES = [ 'entity-schema', 'form', 'item', 'lexeme', 'property', 'sense' ];
public function __construct( array $config = [] ) {
// @phan-suppress-next-line PhanUndeclaredStaticMethod https://github.com/phan/phan/issues/5044
parent::__construct( $config );
$paramType = $config['paramType'] ?? false;
if ( $paramType ) {
if ( in_array( $paramType, self::ALLOWED_TYPES, true ) ) {
$this->paramType = $paramType;
} else {
LoggerFactory::getInstance( 'Math' )->warning(
'Invalid type', [ $paramType ] );
}
}
$this->addClasses( [ 'mw-math-widget-wb-entity-selector' ] );
}
protected function getJavaScriptClassName(): string {
return 'mw.widgets.MathWbEntitySelector';
}
/** @inheritDoc */
public function getConfig( &$config ) {
$config['paramType'] = $this->paramType;
return parent::getConfig( $config );
}
}

File Metadata

Mime Type
text/x-php
Expires
Oct 2 2026, 18:21 (6 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b4/3f/e66e9897f33204de19d908af018d
Default Alt Text
WikibaseEntitySelector.php (1 KB)

Event Timeline