function CKEditor5::mapPairViolationPropertyPathsToFormNames

Same name and namespace in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapPairViolationPropertyPathsToFormNames()
  2. 11.x core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapPairViolationPropertyPathsToFormNames()

Maps Text Editor + Text Format pair property paths to form names.

Parameters

string $property_path: A config object property path.

array $form: The form being checked.

Return value

string The corresponding form name in the complete form.

1 call to CKEditor5::mapPairViolationPropertyPathsToFormNames()
CKEditor5::validateConfigurationForm in core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php
Form validation handler.

File

core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php, line 901

Class

CKEditor5
Defines a CKEditor 5-based text editor for Drupal.

Namespace

Drupal\ckeditor5\Plugin\Editor

Code

protected static function mapPairViolationPropertyPathsToFormNames(string $property_path, array $form) : string {
  // Fundamental compatibility errors are at the root. Map these to the text
  // editor plugin dropdown.
  if ($property_path === '') {
    return 'editor][editor';
  }
  // Filters are top-level.
  if (preg_match('/^filters\\..*/', $property_path)) {
    return implode('][', array_merge(explode('.', $property_path), [
      'settings',
    ]));
  }
  // Image upload settings are stored out-of-band and may also trigger
  // validation errors.
  // @see \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Image
  if (str_starts_with($property_path, 'image_upload.')) {
    $image_upload_setting_property_path = str_replace('image_upload.', '', $property_path);
    return 'editor][settings][plugins][ckeditor5_image][' . implode('][', explode('.', $image_upload_setting_property_path));
  }
  // Everything else is in the subform.
  return 'editor][' . static::mapViolationPropertyPathsToFormNames($property_path, $form);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.