Creates a custom block.
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'.
Drupal\custom_block\Plugin\Core\Entity\CustomBlock Created custom block.
protected function createCustomBlock($title = FALSE, $bundle = 'basic') {
$title = $title ?: $this
->randomName();
if ($custom_block = entity_create('custom_block', array(
'info' => $title,
'type' => $bundle,
'langcode' => 'en',
))) {
$custom_block
->save();
}
return $custom_block;
}