Implements hook_custom_block_insert().
This tests saving a custom_block on custom_block insert.
\Drupal\custom_block\Tests\CustomBlockSaveTest::testCustomBlockSaveOnInsert()
function custom_block_test_custom_block_insert(CustomBlock $custom_block) {
// Set the custom_block title to the custom_block ID and save.
if ($custom_block->info->value == 'new') {
$custom_block->info->value = 'CustomBlock ' . $custom_block->id->value;
$custom_block
->save();
}
if ($custom_block->info->value == 'fail_creation') {
throw new Exception('Test exception for rollback.');
}
}