skin = $skin; $this->htmlData = $htmlData; $this->headingOptions = $headingOptions; $this->actionName = $actionName; $this->classes = $classes; } /** * Generate data needed to create MainMenuAction item. * @param array $htmlData data to make a link or raw html * @param array $headingOptions optional heading for the html * @return array keyed data for the MainMenuAction template */ private function makeMainMenuActionData( array $htmlData = [], array $headingOptions = [] ): array { $skin = $this->skin; $htmlContent = ''; // Populates the main menu as a standalone link or custom html. if ( array_key_exists( 'link', $htmlData ) ) { $htmlContent = $skin->makeLink( 'link', $htmlData['link'] ); } elseif ( array_key_exists( 'html-content', $htmlData ) ) { $htmlContent = $htmlData['html-content']; } if ( !empty( $this->classes ) ) { $headingOptions['class'] = $this->classes; } return $headingOptions + [ 'action' => $this->actionName, 'html-content' => $htmlContent, ]; } /** * @inheritDoc */ public function getTemplateData(): array { return $this->makeMainMenuActionData( $this->htmlData, $this->headingOptions ); } }