Created
January 9, 2019 09:16
-
-
Save Eduardo-Morales-Alberti/3c36a9262f632fef3b81c4b8a9e62f33 to your computer and use it in GitHub Desktop.
Create paragraphs on node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$paragraph_item = Paragraph::create([ | |
'type' => 'html', | |
'title' => 'Testing', | |
'field_texto_largo_con_formato' => 'body test', | |
]); | |
$paragraph_item->save(); | |
$paragraph_w = ParagraphWrapper::create([ | |
'type' => 'html', | |
'title' => 'paragraph wrapper', | |
'paragraph_items' => [ | |
'target_id' => $paragraph_item->id(), | |
'target_revision_id' => $paragraph_item->getRevisionId(), | |
], | |
]); | |
$paragraph_w->save(); | |
// Create node object with attached file. | |
$node = Node::create([ | |
'type' => 'ofertas', | |
'title' => 'Druplicon test 2', | |
'status' => 1, | |
'moderation_state' => 'published', | |
'field_tipo_de_oferta' => 'Empleo', | |
'field_texto_plano' => 'Locaaalización', | |
'field_node_paragraphs' => [ | |
'target_id' => $paragraph_w->id(), | |
'target_revision_id' => $paragraph_w->getRevisionId(), | |
], | |
]); | |
$node->save(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment