custom/plugins/Neon6Configurator/src/Neon6Configurator.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Neon\Configurator;
  3. if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
  4.     require_once dirname(__DIR__) . '/vendor/autoload.php';
  5. }
  6. use Doctrine\DBAL\Connection;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Doctrine\RetryableQuery;
  8. use Shopware\Core\Framework\Plugin;
  9. use Symfony\Component\Filesystem\Filesystem;
  10. class Neon6Configurator extends Plugin
  11. {
  12.     const PAYLOAD_KEY 'neon_configurator';
  13.     const PAYLOAD_KEY_USER_CONFIGURATION 'user_configuration';
  14.     const PAYLOAD_KEY_FIELD_DATA 'field_data';
  15.     const PAYLOAD_KEY_CALCULATIONS 'calculations';
  16.     const PAYLOAD_KEY_WEIGHT 'weight';
  17.     const CUSTOMFIELD_PRODUCTS_CONFIG 'neon_configurator_products_config';
  18.     const CUSTOMFIELD_PRODUCTS_CALCULATION_PREFIX 'neon_configurator_calculation_';
  19.     const CUSTOMFIELD_CATEGORIES_CONFIG 'neon_configurator_categories_config';
  20.     const ADD_LINE_ITEM_KEY 'neon_configurator';
  21.     const FILE_FOLDER 'files/neon-configurator/';
  22.     const PAYLOAD_KEY_BLOCKPRICESELECTION_QUANTITY 'blockprice_selection_quantity';
  23.     const PAYLOAD_KEY_SEPARATE_ITEMS 'neon_configurator_infos';
  24.     public function activate(Plugin\Context\ActivateContext $context): void
  25.     {
  26.     }
  27.     public function deactivate(Plugin\Context\DeactivateContext $context): void
  28.     {
  29.     }
  30.     public function install(Plugin\Context\InstallContext $context): void
  31.     {
  32.     }
  33.     public function uninstall(Plugin\Context\UninstallContext $context): void
  34.     {
  35.         if (!$context->keepUserData()) {
  36.             /** @var Connection $connection */
  37.             $connection $this->container->get('Doctrine\DBAL\Connection');
  38.             $check1 'SET FOREIGN'.'_KEY_CHECKS'.'=0;';
  39.             $check2 'SET FOREIGN'.'_KEY_CHECKS'.'=1;';
  40.             $sql = <<<SQL
  41. $check1
  42. DROP TABLE IF EXISTS `neonconfigurator_fieldvalue_info`;
  43. DROP TABLE IF EXISTS `neonconfigurator_field_info`;
  44. DROP TABLE IF EXISTS `neonconfigurator_info`;
  45. DROP TABLE IF EXISTS `neonconfigurator_fieldvalue`;
  46. DROP TABLE IF EXISTS `neonconfigurator_fieldprice`;
  47. DROP TABLE IF EXISTS `neonconfigurator_fieldvalidation`;
  48. DROP TABLE IF EXISTS `neonconfigurator_fieldcalculation`;
  49. DROP TABLE IF EXISTS `neonconfigurator_fieldvisibility`;
  50. DROP TABLE IF EXISTS `neonconfigurator_commoncalculation`;
  51. DROP TABLE IF EXISTS `neonconfigurator_configuration_media`;
  52. DROP TABLE IF EXISTS `neonconfigurator_configuration`;
  53. DROP TABLE IF EXISTS `neonconfigurator_field`;
  54. DROP TABLE IF EXISTS `neonconfigurator_fieldgroup`;
  55. DROP TABLE IF EXISTS `neonconfigurator_calculation`;
  56. $check2
  57. SQL;
  58.             $connection->executeStatement($sql);
  59.             $sql = <<<SQL
  60. DELETE FROM `custom_field_set` WHERE `name` = 'neon_configurator_products';
  61. DELETE FROM `custom_field_set` WHERE `name` = 'neon_configurator_categories';
  62. SQL;
  63.             $connection->executeStatement($sql);
  64.             $basePath __DIR__ '/../../../../';
  65.             $filesystem = new Filesystem();
  66.             if ($filesystem->exists($basePath self::FILE_FOLDER)) {
  67.                 $filesystem->remove($basePath self::FILE_FOLDER);
  68.             }
  69.         }
  70.     }
  71. }