Uninstall.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Dotdigitalgroup\Email\Setup;
  3. use Magento\Framework\Setup\ModuleContextInterface;
  4. use Magento\Framework\Setup\SchemaSetupInterface;
  5. use Magento\Framework\Setup\UninstallInterface;
  6. class Uninstall implements UninstallInterface
  7. {
  8. /**
  9. * Invoked when remove-data flag is set during module uninstall.
  10. *
  11. * @param SchemaSetupInterface $setup
  12. * @param ModuleContextInterface $context
  13. *
  14. * @return void
  15. */
  16. public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
  17. {
  18. $defaultConnection = $setup->getConnection();
  19. $this->dropTable($setup, Schema::EMAIL_CONTACT_CONSENT_TABLE);
  20. $this->dropTable($setup, Schema::EMAIL_CONTACT_TABLE);
  21. $this->dropTable($setup, Schema::EMAIL_ORDER_TABLE);
  22. $this->dropTable($setup, Schema::EMAIL_CAMPAIGN_TABLE);
  23. $this->dropTable($setup, Schema::EMAIL_REVIEW_TABLE);
  24. $this->dropTable($setup, Schema::EMAIL_WISHLIST_TABLE);
  25. $this->dropTable($setup, Schema::EMAIL_CATALOG_TABLE);
  26. $this->dropTable($setup, Schema::EMAIL_RULES_TABLE);
  27. $this->dropTable($setup, Schema::EMAIL_IMPORTER_TABLE);
  28. $this->dropTable($setup, Schema::EMAIL_AUTOMATION_TABLE);
  29. $this->dropTable($setup, Schema::EMAIL_ABANDONED_CART_TABLE);
  30. $this->dropTable($setup, Schema::EMAIL_FAILED_AUTH_TABLE);
  31. $defaultConnection->dropColumn(
  32. $this->getTableNameWithPrefix($setup, 'admin_user'),
  33. 'refresh_token'
  34. );
  35. $defaultConnection->delete(
  36. $this->getTableNameWithPrefix($setup, 'core_config_data'),
  37. "path LIKE 'connector_api_credentials/%'"
  38. );
  39. }
  40. /**
  41. * @param SchemaSetupInterface $setup
  42. * @param string $tableName
  43. */
  44. private function dropTable(SchemaSetupInterface $setup, $tableName)
  45. {
  46. $connection = $setup->getConnection();
  47. $connection->dropTable($this->getTableNameWithPrefix($setup, $tableName));
  48. }
  49. /**
  50. * @param SchemaSetupInterface $setup
  51. * @param string $tableName
  52. *
  53. * @return string
  54. */
  55. private function getTableNameWithPrefix(SchemaSetupInterface $setup, $tableName)
  56. {
  57. return $setup->getTable($tableName);
  58. }
  59. }