Created
February 29, 2024 08:32
-
-
Save nguyenthanhxuan/f60fc662a59c6359417bb3db42da0955 to your computer and use it in GitHub Desktop.
Create a New Content Entity During Module Update
This file contains 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
<?php | |
use Drupal\Core\Database\Database; | |
/** | |
* Create the entity table if it does not exist. | |
*/ | |
function twist_opsf_update_9001(){ | |
//check if the table exists first. If not, then create the entity. | |
if(!Database::getConnection()->schema()->tableExists('maestro_process_status')) { | |
\Drupal::entityTypeManager()->clearCachedDefinitions(); | |
\Drupal::entityDefinitionUpdateManager() | |
->installEntityType(\Drupal::entityTypeManager()->getDefinition('maestro_process_status')); | |
} else { | |
return 'Process Status entity already exists'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment