Skip to content

Instantly share code, notes, and snippets.

@omarlopesino
Created December 7, 2018 18:49
Show Gist options
  • Save omarlopesino/a1899377a02dc6b01faa78bf11416cd6 to your computer and use it in GitHub Desktop.
Save omarlopesino/a1899377a02dc6b01faa78bf11416cd6 to your computer and use it in GitHub Desktop.
<?php
$paragraph_text = Paragraph::create([
'type' => 'text',
'field_text' => [
'value' => '
<h2>In this page you can publish the failures you consider people might learn of.</h2>
<p><a class="btn btn-primary text-center" href="/node/add/failure" title="Post your own failure!">Post your own failure!</a></p>
',
'format' => 'restricted_html'
],
]);
$paragraph_text->save();
$paragraph_block = Paragraph::create([
'type' => 'block',
'field_block' => [
'plugin_id' => 'views_block:learnfailing_failure_list-block_1',
'settings' => [],
],
]);
$paragraph_block->save();
$node = Node::create([
'type' => 'page',
'uid' => 1,
'title' => 'Welcome!',
'field_bricks' => [
[
'depth' => 0,
'options' => NULL,
'target_id' => $paragraph_text->id(),
],
[
'depth' => 0,
'options' => NULL,
'target_id' => $paragraph_block->id(),
],
],
]);
$node->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment