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. When no value is given, defaults to $this->bundle. Defaults to FALSE.
Drupal\custom_block\Plugin\Core\Entity\CustomBlock Created custom block.
protected function createCustomBlock($title = FALSE, $bundle = FALSE) {
$title = $title ?: $this
->randomName();
$bundle = $bundle ?: $this->bundle;
$custom_block = entity_create('custom_block', array(
'info' => $title,
'type' => $bundle,
'langcode' => 'en',
));
$custom_block
->save();
return $custom_block;
}