computeSmartDefaultSettings example

// If filters were dropped because of a fundamental compatibility problem,       // validate the text format + minimal CKEditor 5 text editor config again       // after dropping those filters from the text format. This allows us to be       // confident that we have caught all fundamental compatibility problems.       if (!empty(array_filter($filters_to_drop))) {
        $post_filter_drop_validation_errors = $this->validatePairToViolationsArray($minimal_valid_cke5_text_editor$text_format, FALSE);
        $this->assertSame($expected_post_filter_drop_fundamental_compatibility_violations$post_filter_drop_validation_errors);
      }
    }

    [$updated_text_editor$messages] = $this->smartDefaultSettings->computeSmartDefaultSettings($text_editor$text_format);

    // Ensure that the result of ::computeSmartDefaultSettings() always complies     // with the config schema.     $this->assertConfigSchema(
      $this->typedConfig,
      $updated_text_editor->getConfigDependencyName(),
      $updated_text_editor->toArray()
    );

    // Save this to ensure the config export order is applied.     // @see \Drupal\Core\Config\StorableConfigBase::castValue()
$language = $this->languageManager->getCurrentLanguage();

    // When enabling CKEditor 5, generate sensible settings from the     // pre-existing text editor/format rather than the hardcoded defaults     // whenever possible.     // @todo Remove after https://www.drupal.org/project/drupal/issues/3226673.     $format = $form_state->getFormObject()->getEntity();
    assert($format instanceof FilterFormatInterface);
    if ($editor->isNew() && !$form_state->get('ckeditor5_is_active') && $form_state->get('ckeditor5_is_selected')) {
      assert($editor->getSettings() === $this->getDefaultSettings());
      if (!$format->isNew()) {
        [$editor$messages] = $this->smartDefaultSettings->computeSmartDefaultSettings($editor$format);
        $form_state->set('used_smart_default_settings', TRUE);
        foreach ($messages as $type => $messages_per_type) {
          foreach ($messages_per_type as $message) {
            $this->messenger()->addMessage($message$type);
          }
        }
        if (isset($messages[MessengerInterface::TYPE_WARNING]) || isset($messages[MessengerInterface::TYPE_ERROR])) {
          $this->messenger()->addMessage($this->t('Check <a href=":handbook">this handbook page</a> for details about compatibility issues of contrib modules.', [
            ':handbook' => 'https://www.drupal.org/node/3273985',
          ]), MessengerInterface::TYPE_WARNING);
        }
      }
Home | Imprint | This part of the site doesn't use cookies.