<?php declare(strict_types=1);
/**
* gb media
* All Rights Reserved.
*
* Unauthorized copying of this file, via any medium is strictly prohibited.
* The content of this file is proprietary and confidential.
*
* @category Shopware
* @package Shopware_Plugins
* @subpackage GbmedEnev
* @copyright Copyright (c) 2019, gb media
* @license proprietary
* @author Giuseppe Bottino
* @link http://www.gb-media.biz
*/
namespace Gbmed\Enev;
use Gbmed\Enev\Core\Content\Enev\EnevDefinition;
use Gbmed\Enev\Core\Content\Enev\Aggregate\EnevTranslation\EnevTranslationDefinition;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
use Doctrine\DBAL\Connection;
class GbmedEnev extends Plugin
{
/**
* changing the storefront script path
*
* @return string
*/
public function getStorefrontScriptPath(): string
{
return 'Resources/dist/storefront/js';
}
public function activate(ActivateContext $context): void
{
parent::activate($context);
$connection = $this->getConnection();
$connection->executeStatement('UPDATE `product_sorting` SET `active`=1 WHERE url_key LIKE "gbmed-enev-%"');
}
public function deactivate(DeactivateContext $context): void
{
parent::deactivate($context);
$connection = $this->getConnection();
$connection->executeStatement('UPDATE `product_sorting` SET `active`=0 WHERE url_key LIKE "gbmed-enev-%"');
}
/**
* removing the plugin data
*
* @param UninstallContext $context
*
* @throws \Doctrine\DBAL\DBALException
*/
public function uninstall(UninstallContext $context): void
{
parent::uninstall($context);
if ($context->keepUserData()) {
return;
}
$connection = $this->getConnection();
$connection->executeStatement('DROP TABLE IF EXISTS `' . EnevTranslationDefinition::ENTITY_NAME . '`');
$connection->executeStatement('DROP TABLE IF EXISTS `' . EnevDefinition::ENTITY_NAME . '`');
$connection->executeStatement('DELETE FROM `product_sorting` WHERE url_key LIKE "gbmed-enev-%"');
$connection->executeStatement('DELETE FROM `import_export_profile` WHERE source_entity LIKE "gbmed_enev"');
}
private function getConnection()
{
return $this->container->get(Connection::class);
}
}