icon = isset( $config['iconElement'] ) ? $config['iconElement'] : new Tag( 'span' ); // Initialization $this->icon->addClasses( [ 'oo-ui-iconElement-icon' ] ); $this->setIcon( isset( $config['icon'] ) ? $config['icon'] : null ); $this->registerConfigCallback( function ( &$config ) { if ( $this->iconName !== null ) { $config['icon'] = $this->iconName; } } ); } /** * Set icon name. * * @param string|null $icon Symbolic icon name * @return $this */ public function setIcon( $icon = null ) { if ( $this->iconName !== null ) { $this->icon->removeClasses( [ 'oo-ui-icon-' . $this->iconName ] ); } if ( $icon !== null ) { $this->icon->addClasses( [ 'oo-ui-icon-' . $icon ] ); } $this->iconName = $icon; $this->toggleClasses( [ 'oo-ui-iconElement' ], (bool)$this->iconName ); return $this; } /** * Get icon name. * * @return string Icon name */ public function getIcon() { return $this->iconName; } /** * Do not use outside of Theme::updateElementClasses * * @protected * @return Tag */ public function getIconElement() { return $this->icon; } }