Debian Codegraph @

extensions/Echo/includes/OOUI/LabelIconWidget.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Notifications\OOUI;
4
5 use OOUI\IconElement;
6 use OOUI\LabelElement;
7 use OOUI\Tag;
8 use OOUI\TitledElement;
9 use OOUI\Widget;
10
11 /**
12 * Widget combining a label and icon
13 */
14 class LabelIconWidget extends Widget {
15 use IconElement;
16 use LabelElement;
17 use TitledElement;
18
19 /**
20 * @param array $config Configuration options
21 * - string|HtmlSnippet $config['label'] Label text
22 * - string $config['title'] Title text
23 * - string $config['icon'] Icon key
24 */
25 public function __construct( $config ) {
26 parent::__construct( $config );
27
28 $tableRow = new Tag( 'div' );
29 $tableRow->setAttributes( [
30 'class' => 'oo-ui-labelIconWidget-row',
31 ] );
32
33 $icon = new Tag( 'div' );
34 $label = new Tag( 'div' );
35
36 $this->initializeIconElement( array_merge( $config, [ 'iconElement' => $icon ] ) );
37 $this->initializeLabelElement( array_merge( $config, [ 'labelElement' => $label ] ) );
38 $this->initializeTitledElement( $config );
39
40 $this->addClasses( [ 'oo-ui-labelIconWidget' ] );
41 $tableRow->appendContent( $icon, $label );
42 $this->appendContent( $tableRow );
43 }
44 }