1<?php 2 3namespace OOUI; 4 5/** 6 * Indicator widget. 7 * 8 * See IndicatorElement for more information. 9 */ 10class IndicatorWidget extends Widget { 11 use IndicatorElement; 12 use TitledElement; 13 use LabelElement; 14 15 /* Static Properties */ 16 17 public static $tagName = 'span'; 18 19 /** 20 * @param array $config Configuration options 21 */ 22 public function __construct( array $config = [] ) { 23 // Parent constructor 24 parent::__construct( $config ); 25 26 // Traits 27 $this->initializeIndicatorElement( 28 array_merge( [ 'indicatorElement' => $this ], $config ) 29 ); 30 $this->initializeTitledElement( 31 array_merge( [ 'titled' => $this ], $config ) 32 ); 33 $this->initializeLabelElement( 34 array_merge( [ 'labelElement' => $this, 'invisibleLabel' => true ], $config ) 35 ); 36 37 // Initialization 38 $this->addClasses( [ 'oo-ui-indicatorWidget' ] ); 39 // Remove class added by LabelElement initialization. It causes unexpected CSS to apply when 40 // nested in other widgets, because this widget used to not mix in LabelElement. 41 $this->removeClasses( [ 'oo-ui-labelElement-label' ] ); 42 43 $this->registerConfigCallback( function ( &$config ) { 44 // We have changed the default value, so change when it is outputted. 45 unset( $config['invisibleLabel'] ); 46 if ( $this->invisibleLabel !== true ) { 47 $config['invisibleLabel'] = $this->invisibleLabel; 48 } 49 } ); 50 } 51} 52