custom/plugins/AvencyShopwareCms/src/AvencyShopwareCms.php line 12

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Avency\Shopware\Cms;
  3. use Avency\Shopware\Cms\Core\PluginHelper;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  6. use Symfony\Component\Config\FileLocator;
  7. use Symfony\Component\DependencyInjection\ContainerBuilder;
  8. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  9. class AvencyShopwareCms extends Plugin
  10. {
  11.     /**
  12.      * Loads dependencies for cms elements
  13.      *
  14.      * @param ContainerBuilder $container
  15.      * @return void
  16.      */
  17.     public function build(ContainerBuilder $container): void
  18.     {
  19.         parent::build($container);
  20.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/Core/Content/DependencyInjection'));
  21.         $loader->load('cms.xml');
  22.         $loader->load('media.xml');
  23.     }
  24.     /**
  25.      * Uninstalls blocks and slots from database
  26.      *
  27.      * @param UninstallContext $uninstallContext
  28.      * @return void
  29.      */
  30.     public function uninstall(UninstallContext $uninstallContext): void
  31.     {
  32.         parent::uninstall($uninstallContext);
  33.         if ($uninstallContext->keepUserData()) {
  34.             return;
  35.         }
  36.         PluginHelper::deleteCmsBlocks($this->container$uninstallContext->getContext());
  37.         PluginHelper::deleteCmsSlots($this->container$uninstallContext->getContext());
  38.     }
  39. }