mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-14 11:16:16 +00:00
ff43e1ecf2
The following sniffs are failing and were disabled: * MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate * MediaWiki.Commenting.FunctionComment.MissingReturn * MediaWiki.Usage.ForbiddenFunctions.isset * MediaWiki.Usage.PHPUnitDeprecatedMethods.AssertInternalTypeGeneric Additional changes: * Also sorted "composer fix" command to run phpcbf last. Change-Id: I29416247ff3736799543926813beaf4afd569a6e
45 lines
1 KiB
PHP
45 lines
1 KiB
PHP
<?php
|
|
|
|
namespace EchoOOUI;
|
|
|
|
use OOUI\IconElement;
|
|
use OOUI\LabelElement;
|
|
use OOUI\Tag;
|
|
use OOUI\TitledElement;
|
|
use OOUI\Widget;
|
|
|
|
/**
|
|
* Widget combining a label and icon
|
|
*/
|
|
class LabelIconWidget extends Widget {
|
|
use IconElement;
|
|
use LabelElement;
|
|
use TitledElement;
|
|
|
|
/**
|
|
* @param array $config Configuration options
|
|
* - string|HtmlSnippet $config['label'] Label text
|
|
* - string $config['title'] Title text
|
|
* - string $config['icon'] Icon key
|
|
*/
|
|
public function __construct( $config ) {
|
|
parent::__construct( $config );
|
|
|
|
$tableRow = new Tag( 'div' );
|
|
$tableRow->setAttributes( [
|
|
'class' => 'oo-ui-labelIconWidget-row',
|
|
] );
|
|
|
|
$icon = new Tag( 'div' );
|
|
$label = new Tag( 'div' );
|
|
|
|
$this->initializeIconElement( array_merge( $config, [ 'iconElement' => $icon ] ) );
|
|
$this->initializeLabelElement( array_merge( $config, [ 'labelElement' => $label ] ) );
|
|
$this->initializeTitledElement( $config );
|
|
|
|
$this->addClasses( [ 'oo-ui-labelIconWidget' ] );
|
|
$tableRow->appendContent( $icon, $label );
|
|
$this->appendContent( $tableRow );
|
|
}
|
|
}
|