function CKEditor5::mapViolationPropertyPathsToFormNames

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

Maps Text Editor config object property paths to form names.

Parameters

string $property_path: A config object property path.

array $subform: The subform being checked.

Return value

string The corresponding form name in the subform.

1 call to CKEditor5::mapViolationPropertyPathsToFormNames()
CKEditor5::mapPairViolationPropertyPathsToFormNames in core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php
Maps Text Editor + Text Format pair property paths to form names.

File

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

Class

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

Namespace

Drupal\ckeditor5\Plugin\Editor

Code

protected static function mapViolationPropertyPathsToFormNames(string $property_path, array $subform) : string {
  $parts = explode('.', $property_path);
  // The "settings" form element does exist, but one level above the Text
  // Editor-specific form. This is operating on a subform.
  $shifted = array_shift($parts);
  assert($shifted === 'settings');
  // It is not required (nor sensible) for the form structure to match the
  // config schema structure 1:1. Automatically identify the relevant form
  // name. Try to be specific. Worst case, an entire plugin settings vertical
  // tab is targeted. (Hence the minimum of 2 parts: the property path gets at
  // minimum mapped to 'toolbar.items' or 'plugins.<plugin ID>'.)
  while (count($parts) > 2 && !NestedArray::keyExists($subform, $parts)) {
    array_pop($parts);
  }
  assert(NestedArray::keyExists($subform, $parts));
  return implode('][', array_merge([
    'settings',
  ], $parts));
}

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