rdbms: Avoid selectDB() call in LoadMonitor new connections
[mediawiki.git] / includes / widget / SelectWithInputWidget.php
blob8faae8225175733cd87fbb56b1551b80888f154b
1 <?php
2 /**
3 * MediaWiki Widgets – SelectWithInputWidget class.
5 * @copyright 2011-2017 MediaWiki Widgets Team and others; see AUTHORS.txt
6 * @license The MIT License (MIT); see LICENSE.txt
7 */
8 namespace MediaWiki\Widget;
10 use \OOUI\TextInputWidget;
11 use \OOUI\DropdownInputWidget;
13 /**
14 * Select and input widget.
16 class SelectWithInputWidget extends \OOUI\Widget {
18 protected $textinput = null;
19 protected $dropdowninput = null;
21 /**
22 * A version of the SelectWithInputWidget, with `or` set to true.
24 * @param array $config Configuration options
25 * @param array $config['textinput'] Configuration for the TextInputWidget
26 * @param array $config['dropdowninput'] Configuration for the DropdownInputWidget
27 * @param boolean $config['or'] Configuration for whether the widget is dropdown AND input
28 * or dropdown OR input
30 public function __construct( array $config = [] ) {
31 // Configuration initialization
32 $config = array_merge(
34 'textinput' => [],
35 'dropdowninput' => [],
36 'or' => false
38 $config
41 // Parent constructor
42 parent::__construct( $config );
44 // Properties
45 $this->config = $config;
46 $this->textinput = new TextInputWidget( $config['textinput'] );
47 $this->dropdowninput = new DropdownInputWidget( $config['dropdowninput'] );
49 // Initialization
50 $this
51 ->addClasses( [ 'mw-widget-selectWithInputWidget' ] )
52 ->appendContent( $this->dropdowninput, $this->textinput );
55 protected function getJavaScriptClassName() {
56 return 'mw.widgets.SelectWithInputWidget';
59 public function getConfig( &$config ) {
60 $config['textinput'] = $this->config['textinput'];
61 $config['dropdowninput'] = $this->config['dropdowninput'];
62 $config['or'] = $this->config['or'];
63 return parent::getConfig( $config );