protected function BlockContentTestBase::createBlockContentType in Drupal 8
Same name in this branch
- 8 core/modules/block_content/src/Tests/BlockContentTestBase.php \Drupal\block_content\Tests\BlockContentTestBase::createBlockContentType()
- 8 core/modules/block_content/tests/src/Functional/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\BlockContentTestBase::createBlockContentType()
- 8 core/modules/block_content/src/Tests/Views/BlockContentTestBase.php \Drupal\block_content\Tests\Views\BlockContentTestBase::createBlockContentType()
- 8 core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\Views\BlockContentTestBase::createBlockContentType()
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 BlockContentTestBase::createBlockContentType()
- BlockContentTestBase::setUp in core/
modules/ block_content/ src/ Tests/ BlockContentTestBase.php - Sets the test up.
File
- core/
modules/ block_content/ src/ Tests/ BlockContentTestBase.php, line 109
Class
- BlockContentTestBase
- Sets up block content types.
Namespace
Drupal\block_content\TestsCode
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;
}