function BlockContentTestHooks::blockContentInsert
Implements hook_block_content_insert().
This tests saving a block_content on block_content insert.
See also
\Drupal\block_content\Tests\BlockContentSaveTest::testBlockContentSaveOnInsert()
File
-
core/
modules/ block_content/ tests/ modules/ block_content_test/ src/ Hook/ BlockContentTestHooks.php, line 62
Class
- BlockContentTestHooks
- Hook implementations for block_content_test.
Namespace
Drupal\block_content_test\HookCode
public function blockContentInsert(BlockContent $block_content) {
// Set the block_content title to the block_content ID and save.
if ($block_content->label() == 'new') {
$block_content->setInfo('BlockContent ' . $block_content->id());
$block_content->setNewRevision(FALSE);
$block_content->save();
}
if ($block_content->label() == 'fail_creation') {
throw new \Exception('Test exception for rollback.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.