Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Eduardo-Morales-Alberti/3b3f21f245b24c5dc4857e19f629c65e to your computer and use it in GitHub Desktop.
Save Eduardo-Morales-Alberti/3b3f21f245b24c5dc4857e19f629c65e to your computer and use it in GitHub Desktop.
Edit paragraph wrapper Drupal 8
use Drupal\paragraphs\Entity\Paragraph;
$p_wrapper = \Drupal::entityTypeManager()->getStorage('paragraph_wrapper')->load('17522');
$paragraph_item = Paragraph::create([
'type' => 'html',
'title' => 'Testing',
'field_texto_largo_con_formato' => 'body test',
]);
$paragraph_item->save();
$p_wrapper->set('paragraph_items', [
[
'target_id' => $paragraph_item->id(),
'target_revision_id' => $paragraph_item->getRevisionId(),
],
]);
$p_wrapper->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment