Uninstall.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Setup;
  6. use Magento\Catalog\Model\Product;
  7. use Magento\Eav\Setup\EavSetupFactory;
  8. use Magento\Framework\App\ResourceConnection;
  9. use Magento\Framework\Setup\ModuleContextInterface;
  10. use Magento\Framework\Setup\SchemaSetupInterface;
  11. use Magento\Framework\Setup\UninstallInterface;
  12. /**
  13. * Uninstall
  14. *
  15. * @package Temando\Shipping\Setup
  16. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  17. * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  18. * @link https://www.temando.com/
  19. */
  20. class Uninstall implements UninstallInterface
  21. {
  22. /**
  23. * @var EavSetupFactory
  24. */
  25. private $eavSetupFactory;
  26. /**
  27. * Uninstall constructor.
  28. * @param EavSetupFactory $eavSetupFactory
  29. */
  30. public function __construct(EavSetupFactory $eavSetupFactory)
  31. {
  32. $this->eavSetupFactory = $eavSetupFactory;
  33. }
  34. /**
  35. * Remove data that was created during module installation.
  36. *
  37. * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $setup
  38. * @param ModuleContextInterface $context
  39. *
  40. * @return void
  41. */
  42. public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
  43. {
  44. $uninstaller = $setup;
  45. $defaultConnection = $uninstaller->getConnection(ResourceConnection::DEFAULT_CONNECTION);
  46. $checkoutConnection = $uninstaller->getConnection(SetupSchema::CHECKOUT_CONNECTION_NAME);
  47. $salesConnection = $uninstaller->getConnection(SetupSchema::SALES_CONNECTION_NAME);
  48. $salesConnection->dropTable(SetupSchema::TABLE_ORDER);
  49. $checkoutConnection->dropTable(SetupSchema::TABLE_QUOTE_COLLECTION_POINT);
  50. $checkoutConnection->dropTable(SetupSchema::TABLE_COLLECTION_POINT_SEARCH);
  51. $checkoutConnection->dropTable(SetupSchema::TABLE_ORDER_COLLECTION_POINT);
  52. $checkoutConnection->dropTable(SetupSchema::TABLE_QUOTE_PICKUP_LOCATION);
  53. $checkoutConnection->dropTable(SetupSchema::TABLE_PICKUP_LOCATION_SEARCH);
  54. $checkoutConnection->dropTable(SetupSchema::TABLE_ORDER_PICKUP_LOCATION);
  55. $checkoutConnection->dropTable(SetupSchema::TABLE_CHECKOUT_ADDRESS);
  56. $salesConnection->dropTable(SetupSchema::TABLE_SHIPMENT);
  57. $defaultConnection->dropTable(RmaSetupSchema::TABLE_RMA_SHIPMENT);
  58. $eavSetup = $this->eavSetupFactory->create();
  59. $eavSetup->removeAttribute(Product::ENTITY, SetupData::ATTRIBUTE_CODE_HEIGHT);
  60. $eavSetup->removeAttribute(Product::ENTITY, SetupData::ATTRIBUTE_CODE_WIDTH);
  61. $eavSetup->removeAttribute(Product::ENTITY, SetupData::ATTRIBUTE_CODE_LENGTH);
  62. $configTable = $uninstaller->getTable('core_config_data');
  63. $defaultConnection->delete($configTable, "`path` LIKE 'carriers/temando/%'");
  64. }
  65. }