indicator = $config['indicatorElement'] ?? new Tag( 'span' ); // Initialization $this->indicator->addClasses( [ 'oo-ui-indicatorElement-indicator' ] ); $this->setIndicator( $config['indicator'] ?? null ); $this->registerConfigCallback( function ( &$config ) { if ( $this->indicatorName !== null ) { $config['indicator'] = $this->indicatorName; } } ); } /** * Set indicator name. * * @param string|null $indicator Symbolic name of indicator to use or null for no indicator * @return $this */ public function setIndicator( $indicator = null ) { if ( $this->indicatorName !== null ) { $this->indicator->removeClasses( [ 'oo-ui-indicator-' . $this->indicatorName ] ); } if ( $indicator !== null ) { $this->indicator->addClasses( [ 'oo-ui-indicator-' . $indicator ] ); } $this->indicatorName = $indicator; $this->toggleClasses( [ 'oo-ui-indicatorElement' ], (bool)$this->indicatorName ); $this->indicator->toggleClasses( [ 'oo-ui-indicatorElement-noIndicator' ], !$this->indicatorName ); return $this; } /** * Get indicator name. * * @return string|null Symbolic name of indicator, null if not set */ public function getIndicator() { return $this->indicatorName; } /** * Do not use outside of Theme::updateElementClasses * * @protected * @return Tag */ public function getIndicatorElement() { return $this->indicator; } /** * Toggle CSS classes. * * @param array $classes List of classes to add * @param bool|null $toggle Add classes * @return $this */ abstract public function toggleClasses( array $classes, $toggle = null ); /** * @param callable $func */ abstract public function registerConfigCallback( callable $func ); }