function hook_paragraphs_conversion_alter

Alters the paragraphs after conversion.

This hook is fired once per converted paragraph entity. The hook implementations must handle paragraphs translations on their own.


\Drupal\paragraphs\ParagraphInterface $original: The original paragraph entity.

\Drupal\paragraphs\ParagraphInterface $converted: The converted paragraph entity.

1 invocation of hook_paragraphs_conversion_alter()
ParagraphsWidget::paragraphsConvertSubmit in paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php
The submit callback to complete the paragraphs conversion.


paragraphs/paragraphs.api.php, line 63
Hooks and documentation related to paragraphs module.


function hook_paragraphs_conversion_alter(ParagraphInterface $original, ParagraphInterface $converted) {

  // Alter the converted text value.
  if ($converted
    ->bundle() == 'text_image') {
    $field_name = 'field_text_demo';
    if ($converted
      ->hasField($field_name) && !$converted
      ->isEmpty()) {
      $value = implode(', ', [
        ->set($field_name, $value);