<?php declare(strict_types=1);
namespace Avency\Shopware\Cms;
use Avency\Shopware\Cms\Core\PluginHelper;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
class AvencyShopwareCms extends Plugin
{
/**
* Loads dependencies for cms elements
*
* @param ContainerBuilder $container
* @return void
*/
public function build(ContainerBuilder $container): void
{
parent::build($container);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/Core/Content/DependencyInjection'));
$loader->load('cms.xml');
$loader->load('media.xml');
}
/**
* Uninstalls blocks and slots from database
*
* @param UninstallContext $uninstallContext
* @return void
*/
public function uninstall(UninstallContext $uninstallContext): void
{
parent::uninstall($uninstallContext);
if ($uninstallContext->keepUserData()) {
return;
}
PluginHelper::deleteCmsBlocks($this->container, $uninstallContext->getContext());
PluginHelper::deleteCmsSlots($this->container, $uninstallContext->getContext());
}
}