Removing a Block Upon Package Upgrade
PermalinkBelow is the code that I have in my package controller for the upgrade:
public function upgrade() { parent::upgrade(); $db = Loader::db(); $db->Execute('DROP TABLE IF EXISTS btFitTextBeta'); }
The name of the block I'm removing in the new version is "Fit Text Beta".
Is the above code correct, or is there anything else I need to add?
public function upgrade() { parent::upgrade(); BlockType::getByHandle('btFitTextBeta')->controller->uninstall(); $db = Loader::db(); $db->Execute('DROP TABLE IF EXISTS btFitTextBeta'); }
If you are replacing a block with a redevelopment, it would be a friendlier upgrade to migrate instances of the old block into the new block so content doesn't get lost in the process.
I suspect that if you look inside 'uninstall' there will be code that removes a block type in a more sympathetic way.