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; } /** * Override the icon used in the home menu entry. * * @param string $icon * @return $this */ public function overrideIcon( $icon ) { $this->component['icon'] = $icon; 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, 'icon' => 'minerva-' . $name, ]; if ( $trackClicks !== false ) { $eventName = $trackClicks === true ? $name : $trackClicks; $this->component['data-event-name'] = 'menu.' . $eventName; } } /** * @inheritDoc */ public function getName() { return $this->name; } /** * @inheritDoc */ public function getCSSClasses(): array { return []; } /** * @inheritDoc */ public function getComponents(): array { return [ $this->component ]; } }