custom/plugins/CustomFieldFilter/src/CustomFieldFilter.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace CustomFieldFilter;
  3. use Shopware\Core\Framework\Plugin;
  4. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  5. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  6. use Doctrine\DBAL\Connection;
  7. class CustomFieldFilter extends Plugin
  8. {
  9.     public function install(InstallContext $installContext): void
  10.     {
  11.         parent::install($installContext);
  12.         $connection $this->container->get(Connection::class);
  13.         $connection->executeStatement("
  14.             CREATE TABLE IF NOT EXISTS `as_custom_fields_filter`
  15.             (
  16.                 `id`                BINARY(16)   NOT NULL,
  17.                 `custom_field_id`   BINARY(16)   NOT NULL,
  18.                 `type`              VARCHAR(255) NOT NULL,
  19.                 `display_name` VARCHAR(255) NOT NULL,
  20.                 `request_parameter` VARCHAR(255) NOT NULL,
  21.                 `active`            TINYINT(1)   NULL DEFAULT '0',
  22.                 `position`          INT(11)      NULL DEFAULT '0',
  23.                 `created_at`        DATETIME(3)  NOT NULL,
  24.                 `updated_at`        DATETIME(3)  NULL,
  25.                 PRIMARY KEY (`id`),
  26.                 KEY `fk.custom_fields_filter.custom_field_id` (`custom_field_id`),
  27.                 CONSTRAINT `fk.custom_fields_filter.custom_field_id` FOREIGN KEY (`custom_field_id`) REFERENCES `custom_field` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
  28.             ) ENGINE = InnoDB
  29.               DEFAULT CHARSET = utf8mb4
  30.               COLLATE = utf8mb4_unicode_ci;
  31.         ");
  32.     }
  33.     public function uninstall(UninstallContext $uninstallContext): void
  34.     {
  35.         $connection $this->container->get(Connection::class);
  36.         $connection->executeStatement("DROP TABLE IF EXISTS `as_custom_fields_filter`");
  37.     }
  38. }