function _paragraphs_collection_demo_create_text_paragraph

Helper function to create paragraph text.

Parameters

string $text: Paragraph text.

string $format: Text format.

Return value

\Drupal\Core\Entity\EntityInterface Paragraphs text entity.

2 calls to _paragraphs_collection_demo_create_text_paragraph()
_paragraphs_collection_demo_create_demo_article in paragraphs_collection/modules/paragraphs_collection_demo/paragraphs_collection_demo.install
Create demo article example.
_paragraphs_collection_demo_create_grid_article in paragraphs_collection/modules/paragraphs_collection_demo/paragraphs_collection_demo.install
Create demo grid article example.

File

paragraphs_collection/modules/paragraphs_collection_demo/paragraphs_collection_demo.install, line 513
Installation hooks for paragraphs_collection_demo module.

Code

function _paragraphs_collection_demo_create_text_paragraph($text, $format = 'basic_html') {
  $text_paragraph = Paragraph::create([
    'type' => 'text',
    'paragraphs_text' => [
      'value' => $text,
      'format' => $format,
    ],
  ]);
  $text_paragraph
    ->save();
  return $text_paragraph;
}