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