Created
August 4, 2020 06:33
-
-
Save larowlan/79ad819ebb65363f3b8ea732223a28b1 to your computer and use it in GitHub Desktop.
Create a missing block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a missing block (with empty fields but matching UUID). | |
*/ | |
function yourmodule_post_update_create_a_missing_block() { | |
$block_entity_manager = \Drupal::service('entity.manager')->getStorage('block_content'); | |
$missing_uuid = 'CE7DA6B0-C2A0-4EE9-8F6B-8854A3705FB7'; | |
$block = $block_entity_manager->create([ | |
'info' => 'Block title goes here', | |
'type' => 'block_type_machine_name_here', | |
'uuid' => $missing_uuid, | |
]); | |
$block->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment