<?php declare(strict_types=1);
namespace Eightworks\EightworksCookieConsentPlus6;
/**
* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
* ______ ________ _______ ______ __ __ _______
* | __ | | | | | __ \ |/ | __|
* | __ | | | | - | < <|__ |
* |______|________|_______|___|__|__|\__|_______|
*
* ####+++--- C O N T A C T –--++++####
*
* Internetagentur 8works
* WEB: 8works.de
* MAIL: info@8works.de
*
* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
**/
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter;
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;
class EightworksCookieConsentPlus6 extends Plugin
{
public function boot(): void
{
parent::boot();
}
/**
* Install plugin
*
* @param InstallContext $context
* @return void
*/
public function install(InstallContext $context) : void
{
parent::install($context);
}
/**
* Uninstall plugin
*
* @param UninstallContext $context
* @return void
*/
public function uninstall(UninstallContext $context): void
{
parent::uninstall($context);
if ($context->keepUserData()) {
return;
}
$this->removeConfiguration($context->getContext());
}
/**
* Remove configuration
*
* @param Context $context
* @return void
*/
private function removeConfiguration(Context $context): void
{
/** @var EntityRepositoryInterface $systemConfigRepository */
$systemConfigRepository = $this->container->get('system_config.repository');
$criteria = (new Criteria())->addFilter(new ContainsFilter('configurationKey', $this->getName() . '.config.'));
$idSearchResult = $systemConfigRepository->searchIds($criteria, $context);
$ids = array_map(static function ($id) {
return ['id' => $id];
}, $idSearchResult->getIds());
if ($ids === []) {
return;
}
$systemConfigRepository->delete($ids, $context);
}
/**
* Activate plugin
*
* @param ActivateContext $context
* @return void
*/
public function activate(ActivateContext $context) : void
{
parent::activate($context);
}
/**
* Deactivate plugin
*
* @param DeactivateContext $context
* @return void
*/
public function deactivate(DeactivateContext $context) : void
{
parent::deactivate($context);
}
}