custom/plugins/MoorlCmsTestimonial/src/MoorlCmsTestimonial.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace MoorlCmsTestimonial;
  3. use MoorlFoundation\Core\PluginFoundation;
  4. use MoorlFoundation\Core\Service\DataService;
  5. use Shopware\Core\Framework\Plugin;
  6. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  7. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8. use Symfony\Component\Config\FileLocator;
  9. use Symfony\Component\DependencyInjection\ContainerBuilder;
  10. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  11. class MoorlCmsTestimonial extends Plugin
  12. {
  13.     public const NAME 'MoorlCmsTestimonial';
  14.     public const DATA_CREATED_AT '2022-03-21 00:00:00.000';
  15.     public const PLUGIN_TABLES = [
  16.         'moorl_testimonial',
  17.         'moorl_testimonial_translation',
  18.     ];
  19.     public const SHOPWARE_TABLES = [
  20.         'media_default_folder',
  21.         'moorl_sorting'
  22.     ];
  23.     public function build(ContainerBuilder $container): void
  24.     {
  25.         parent::build($container);
  26.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/Content/DependencyInjection'));
  27.         $loader->load('media.xml');
  28.     }
  29.     public function activate(ActivateContext $activateContext): void
  30.     {
  31.         parent::activate($activateContext);
  32.         /* @var $dataService DataService */
  33.         $dataService $this->container->get(DataService::class);
  34.         $dataService->install(self::NAME);
  35.     }
  36.     public function uninstall(UninstallContext $context): void
  37.     {
  38.         parent::uninstall($context);
  39.         if ($context->keepUserData()) {
  40.             return;
  41.         }
  42.         /* @var $foundation PluginFoundation */
  43.         $foundation $this->container->get(PluginFoundation::class);
  44.         $foundation->setContext($context->getContext());
  45.         $foundation->removeCmsSlots(['moorl-testimonial']);
  46.         $foundation->removeCmsBlocks(['moorl-testimonial-three-column']);
  47.     }
  48. }