<?php declare(strict_types=1);namespace Dmits\InquirySales;use Shopware\Core\Framework\Plugin;use Shopware\Core\Framework\Context;use Shopware\Core\Framework\Plugin\Context\ActivateContext;use Shopware\Core\Framework\Plugin\Context\DeactivateContext;use Shopware\Core\Framework\Plugin\Context\InstallContext;use Shopware\Core\Framework\Plugin\Context\UninstallContext;use Shopware\Core\Framework\CustomField\CustomFieldTypes;use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;use Shopware\Core\Framework\DataAbstractionLayer\Search\IdSearchResult;use Shopware\Core\System\SystemConfig\SystemConfigDefinition;use Doctrine\DBAL\Connection;use Shopware\Core\Framework\Uuid\Uuid;use Shopware\Core\Defaults;use Composer\InstalledVersions;use Dmits\InquirySales\CustomFields\CustomFieldUpdater;class DmitsInquirySales extends Plugin{ private function getCustomFieldUpdater() { /** * @var EntityRepositoryInterface $customFieldSetRepository */ $customFieldSetRepository = $this->container->get('custom_field_set.repository'); /** * @var EntityRepositoryInterface $customFieldRepository */ $customFieldRepository = $this->container->get('custom_field.repository'); return new CustomFieldUpdater( $customFieldSetRepository, $customFieldRepository, $this->path ); } public function getViewPaths(): array { $viewPaths = parent::getViewPaths(); $viewPaths[] = 'Resources/views/storefront'; return $viewPaths; } public function activate(ActivateContext $context): void { $this->getCustomFieldUpdater()->sync(); parent::activate($context); } public function deactivate(DeactivateContext $context): void { $shopwareContext = $context->getContext(); parent::deactivate($context); } public function install(InstallContext $context): void { parent::install($context); $this->getCustomFieldUpdater()->sync(); } public function uninstall(UninstallContext $context): void { parent::uninstall($context); $shopwareVersion = InstalledVersions::getVersion('shopware/core'); if ($context->keepUserData()) return; $this->getCustomFieldUpdater()->remove(); try{ $connection = $this->container->get(Connection::class); if (version_compare($shopwareVersion, '6.4', '>=')) { $connection->exec('DROP TABLE IF EXISTS `dmits_inquirysales_distributions`'); $connection->exec('DROP TABLE IF EXISTS `dmits_inquirysales_requests`'); }else{ $connection->executeQuery('DROP TABLE IF EXISTS `dmits_inquirysales_distributions`'); $connection->executeQuery('DROP TABLE IF EXISTS `dmits_inquirysales_requests`'); } } catch(\Exception $e){ } } }