Debian Codegraph @

vendor/oojs/oojs-ui/php/widgets/IconWidget.php

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