accessKeyed = $config['accessKeyed'] ?? $this; // Initialization $this->setAccessKey( $config['accessKey'] ?? null ); $this->registerConfigCallback( function ( &$config ) { if ( $this->accessKey !== null ) { $config['accessKey'] = $this->accessKey; } } ); } /** * Set access key. * * @param string $accessKey Tag's access key, use empty string to remove * @return $this */ public function setAccessKey( $accessKey ) { $accessKey = is_string( $accessKey ) && strlen( $accessKey ) ? $accessKey : null; if ( $this->accessKey !== $accessKey ) { if ( $accessKey !== null ) { $this->accessKeyed->setAttributes( [ 'accesskey' => $accessKey ] ); } else { $this->accessKeyed->removeAttributes( [ 'accesskey' ] ); } $this->accessKey = $accessKey; // Only if this is a TitledElement if ( method_exists( $this, 'updateTitle' ) ) { $this->updateTitle(); } } return $this; } /** * Get access key. * * @return string Access key string */ public function getAccessKey() { return $this->accessKey; } /** * Add information about the access key to the element's tooltip label. * (This is only public for hacky usage in FieldLayout.) * * @param string $title Tooltip label for `title` attribute * @return string */ public function formatTitleWithAccessKey( $title ) { $accessKey = $this->getAccessKey(); if ( $accessKey ) { $title .= " [$accessKey]"; } return $title; } }