function QuickEditIntegrationTest::createBlockContent

Creates a custom block.

Parameters

bool|string $title: (optional) Title of block. When no value is given uses a random name. Defaults to FALSE.

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 QuickEditIntegrationTest::createBlockContent()
QuickEditIntegrationTest::testCustomBlockLinks in core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
Tests that contextual links in custom blocks are changed.

File

core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php, line 171

Class

QuickEditIntegrationTest
Test Settings Tray and Quick Edit modules integration.

Namespace

Drupal\Tests\settings_tray\FunctionalJavascript

Code

protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) {
    $title = $title ?: $this->randomName();
    $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.