function SettingsTrayIntegrationTest::createBlockContent

Creates a custom block.

Parameters

string $title: Title of block.

string $bundle: (optional) Bundle name. Defaults to 'basic'.

bool $save: (optional) Whether to save the block. Defaults to TRUE.

Return value

\Drupal\block_content\Entity\BlockContent Created custom block.

1 call to SettingsTrayIntegrationTest::createBlockContent()
SettingsTrayIntegrationTest::testCustomBlockLinks in core/modules/quickedit/tests/src/FunctionalJavascript/SettingsTrayIntegrationTest.php
Tests that contextual links in custom blocks are changed.

File

core/modules/quickedit/tests/src/FunctionalJavascript/SettingsTrayIntegrationTest.php, line 182

Class

SettingsTrayIntegrationTest
Test Settings Tray and Quick Edit modules integration.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

protected function createBlockContent(string $title, string $bundle = 'basic', bool $save = TRUE) : BlockContent {
    $block_content = BlockContent::create([
        'info' => $title,
        'type' => $bundle,
        'langcode' => 'en',
        'body' => [
            'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
            'format' => 'plain_text',
        ],
    ]);
    if ($block_content && $save === TRUE) {
        $block_content->save();
    }
    return $block_content;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.