vendor/store.shopware.com/swagdynamicaccess/src/SwagDynamicAccess.php line 20

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /*
  3.  * (c) shopware AG <info@shopware.com>
  4.  * For the full copyright and license information, please view the LICENSE
  5.  * file that was distributed with this source code.
  6.  */
  7. namespace Swag\DynamicAccess;
  8. use Doctrine\DBAL\Connection;
  9. use Shopware\Core\Framework\Plugin;
  10. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  11. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  12. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  13. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  14. use Swag\DynamicAccess\DataAbstractionLayer\CategoryRule\CategoryRuleDefinition;
  15. use Swag\DynamicAccess\DataAbstractionLayer\LandingPageRule\LandingPageRuleDefinition;
  16. use Swag\DynamicAccess\DataAbstractionLayer\ProductRule\ProductRuleDefinition;
  17. class SwagDynamicAccess extends Plugin
  18. {
  19.     public function activate(ActivateContext $activateContext): void
  20.     {
  21.         parent::activate($activateContext);
  22.     }
  23.     public function deactivate(DeactivateContext $deactivateContext): void
  24.     {
  25.         parent::deactivate($deactivateContext);
  26.     }
  27.     public function uninstall(UninstallContext $uninstallContext): void
  28.     {
  29.         if ($uninstallContext->keepUserData()) {
  30.             return;
  31.         }
  32.         $this->removeTables();
  33.     }
  34.     public function update(UpdateContext $updateContext): void
  35.     {
  36.         parent::update($updateContext);
  37.     }
  38.     public function enrichPrivileges(): array
  39.     {
  40.         return [];
  41.     }
  42.     private function removeTables(): void
  43.     {
  44.         $connection $this->container->get(Connection::class);
  45.         $classNames = [
  46.             CategoryRuleDefinition::ENTITY_NAME,
  47.             LandingPageRuleDefinition::ENTITY_NAME,
  48.             ProductRuleDefinition::ENTITY_NAME,
  49.         ];
  50.         foreach ($classNames as $className) {
  51.             $connection->executeStatement(\sprintf('DROP TABLE IF EXISTS `%s`'$className));
  52.         }
  53.     }
  54. }