custom/plugins/DvsnPersistentCart/src/DvsnPersistentCart.php line 21

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * digitvision
  4.  *
  5.  * @category  digitvision
  6.  * @package   Shopware\Plugins\DvsnPersistentCart
  7.  * @copyright (c) 2020 digitvision
  8.  */
  9. namespace Dvsn\PersistentCart;
  10. use Doctrine\DBAL\Connection;
  11. use Shopware\Core\Framework\Plugin;
  12. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  13. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  14. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  15. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  16. use Symfony\Component\DependencyInjection\ContainerBuilder;
  17. class DvsnPersistentCart extends Plugin
  18. {
  19.     /**
  20.      * {@inheritDoc}
  21.      */
  22.     public function build(ContainerBuilder $container): void
  23.     {
  24.         // set plugin parameters
  25.         $container->setParameter('dvsn.persistent_cart.path'$this->getPath());
  26.         // call parent
  27.         parent::build($container);
  28.     }
  29.     /**
  30.      * {@inheritDoc}
  31.      */
  32.     public function activate(ActivateContext $activateContext): void
  33.     {
  34.     }
  35.     /**
  36.      * {@inheritDoc}
  37.      */
  38.     public function install(InstallContext $installContext): void
  39.     {
  40.         // call installer
  41.         $installer = new Setup\Install(
  42.             $this,
  43.             $installContext,
  44.             $this->container->get(Connection::class),
  45.             $this->container->get('custom_field_set.repository'),
  46.             $this->container->get('custom_field.repository'),
  47.             $this->container->get('number_range.repository'),
  48.             $this->container->get('mail_template.repository'),
  49.             $this->container->get('document_type.repository'),
  50.             $this->container->get('document_base_config.repository')
  51.         );
  52.         $installer->install();
  53.         // call updater
  54.         $installer = new Setup\Update(
  55.             $this,
  56.             $installContext,
  57.             $this->container->get(Connection::class),
  58.             $this->container->get('custom_field_set.repository'),
  59.             $this->container->get('custom_field.repository')
  60.         );
  61.         $installer->install();
  62.     }
  63.     /**
  64.      * {@inheritDoc}
  65.      */
  66.     public function postInstall(InstallContext $installContext): void
  67.     {
  68.     }
  69.     /**
  70.      * {@inheritDoc}
  71.      */
  72.     public function update(UpdateContext $updateContext): void
  73.     {
  74.         // call updater
  75.         $installer = new Setup\Update(
  76.             $this,
  77.             $updateContext,
  78.             $this->container->get(Connection::class),
  79.             $this->container->get('custom_field_set.repository'),
  80.             $this->container->get('custom_field.repository')
  81.         );
  82.         $installer->update($updateContext->getCurrentPluginVersion());
  83.     }
  84.     /**
  85.      * {@inheritDoc}
  86.      */
  87.     public function postUpdate(UpdateContext $updateContext): void
  88.     {
  89.     }
  90.     /**
  91.      * {@inheritDoc}
  92.      */
  93.     public function uninstall(UninstallContext $context): void
  94.     {
  95.         // call uninstaller
  96.         $installer = new Setup\Uninstall(
  97.             $this,
  98.             $context,
  99.             $this->container->get(Connection::class),
  100.             $this->container->get('custom_field_set.repository'),
  101.             $this->container->get('custom_field.repository')
  102.         );
  103.         $installer->uninstall();
  104.     }
  105. }