component['text'] = $text; return $this; } /** * Override the CSS class used in the home menu entry. * * @param string $cssClass * @return $this */ public function overrideCssClass( $cssClass ) { $this->component['class'] = $cssClass; return $this; } /** * Create a home menu element with one component * * @param string $name An unique menu element identifier * @param string $text Text to show on menu element * @param string $url URL menu element points to * @param bool|string $trackClicks Should clicks be tracked. To override the tracking code * pass the tracking code as string */ public function __construct( $name, $text, $url, $trackClicks = true ) { $this->name = $name; $this->component = [ 'text' => $text, 'href' => $url, 'class' => trim( MinervaUI::iconClass( $name, 'before' ) ) ]; if ( $trackClicks !== false ) { $this->component['data-event-name'] = $trackClicks === true ? $name : $trackClicks; } } /** * @inheritDoc */ public function getName() { return $this->name; } /** * @inheritDoc */ public function getCSSClasses(): array { return []; } /** * @inheritDoc */ public function getComponents(): array { return [ $this->component ]; } }