| 1 |
<?php |
| 2 |
|
| 3 |
namespace OOUI; |
| 4 |
|
| 5 |
class TabOptionWidget extends OptionWidget { |
| 6 |
|
| 7 |
/** @var string|null */ |
| 8 |
protected $href; |
| 9 |
|
| 10 |
/** |
| 11 |
* @param array $config Configuration options |
| 12 |
* - string $config['href'] Hyperlink to add to TabOption. Mostly used in OOUI PHP. |
| 13 |
*/ |
| 14 |
public function __construct( array $config = [] ) { |
| 15 |
$this->href = $config['href'] ?? false; |
| 16 |
if ( $this->href ) { |
| 17 |
$link = new Tag( 'a' ); |
| 18 |
$link->setAttributes( [ 'href' => $config['href'] ] ); |
| 19 |
$config = array_merge( [ |
| 20 |
'labelElement' => $link |
| 21 |
], $config ); |
| 22 |
} |
| 23 |
|
| 24 |
// Parent constructor |
| 25 |
parent::__construct( $config ); |
| 26 |
|
| 27 |
// Initialisation |
| 28 |
$this->addClasses( [ 'oo-ui-tabOptionWidget' ] ); |
| 29 |
$this->setAttributes( [ |
| 30 |
'role' => 'tab' |
| 31 |
] ); |
| 32 |
} |
| 33 |
|
| 34 |
/** @inheritDoc */ |
| 35 |
public function getConfig( &$config ) { |
| 36 |
if ( $this->href ) { |
| 37 |
$config['href'] = $this->href; |
| 38 |
} |
| 39 |
return parent::getConfig( $config ); |
| 40 |
} |
| 41 |
} |