This is the current construct method of the file:
public function __construct( Url|string $url, string $languageString, string $css ='ipsMenu_item', array $dataAttributes = [], bool $opensDialog = FALSE, ?string $icon = NULL, string $id = NULL, string $identifier = '' ) { $this->url = $url; $this->title = $languageString; $this->css = $css; $this->dataAttributes = $dataAttributes; $this->icon = $icon; $this->menuItem = $identifier ?: $languageString; if( !$id ) { $id = 'menuLink_' . md5($languageString ) . '_' . $this->identifier; } $this->id = $id; if( $opensDialog ) { $this->opensDialog(); } $this->addAttribute( 'data-menuItem', $languageString); }
Here's a list of issues:
- The $this->identifier variable is always empty when used to create a missing $id.
- The last line that adds the data-menuItem attribute should use $this->menuItem rather than $languageString.
- [Not really a bug] After the class values are set at the top you should use those rather than the function variables.
Here's the updated code with all the changes if you want to copy/paste it. 😋
public function __construct( Url|string $url, string $languageString, string $css ='ipsMenu_item', array $dataAttributes = [], bool $opensDialog = FALSE, ?string $icon = NULL, string $id = NULL, string $identifier = '' ) { $this->url = $url; $this->title = $languageString; $this->css = $css; $this->dataAttributes = $dataAttributes; $this->icon = $icon; $this->identifier = $identifier; $this->menuItem = $this->identifier ?: $this->title; if( !$id ) { $id = 'menuLink_' . md5($this->title ) . '_' . $this->identifier; } $this->id = $id; if( $opensDialog ) { $this->opensDialog(); } $this->addAttribute( 'data-menuItem', $this->menuItem ); }
Recommended Comments