You are here

protected function SettingsTrayIntegrationTest::createBlockContentType in Drupal 9

Creates a custom block type (bundle).

Parameters

string $label: The block type label.

bool $create_body: Whether or not to create the body field.

Return value

\Drupal\block_content\Entity\BlockContentType Created custom block type.

1 call to SettingsTrayIntegrationTest::createBlockContentType()
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 200

Class

SettingsTrayIntegrationTest
Test Settings Tray and Quick Edit modules integration.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

protected function createBlockContentType($label, $create_body = FALSE) {
  $bundle = BlockContentType::create([
    'id' => $label,
    'label' => $label,
    'revision' => FALSE,
  ]);
  $bundle
    ->save();
  if ($create_body) {
    block_content_add_body_field($bundle
      ->id());
  }
  return $bundle;
}