function Contrib::mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem
Maps a CKEditor 4 button to the CKEditor 5 equivalent, if it exists.
Generated by inspecting all \Drupal\ckeditor\CKEditorPluginButtonsInterface implementations.
Parameters
string $cke4_button: A valid CKEditor 4 button name.
\Drupal\ckeditor5\HTMLRestrictions $text_format_html_restrictions: The restrictions of the text format, if this upgrade plugin needs to inspect the text format's HTML restrictions to make a decision.
Return value
string[]|null The equivalent CKEditor 5 toolbar items, or NULL if no equivalent exists. In either case, the button names must be added to the annotation.
Overrides CKEditor4To5UpgradePluginInterface::mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem
File
- 
              core/
modules/ ckeditor5/ src/ Plugin/ CKEditor4To5Upgrade/ Contrib.php, line 38  
Class
- Contrib
 - Provides the CKEditor 4 to 5 upgrade path for contrib plugins now in core.
 
Namespace
Drupal\ckeditor5\Plugin\CKEditor4To5UpgradeCode
public function mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem(string $cke4_button, HTMLRestrictions $text_format_html_restrictions) : ?array {
  switch ($cke4_button) {
    // @see https://www.drupal.org/project/codetag
    case 'Code':
      return [
        'code',
      ];
    // @see https://www.drupal.org/project/codesnippet
    case 'CodeSnippet':
      return [
        'codeBlock',
      ];
    default:
      throw new \OutOfBoundsException();
  }
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.