custom/plugins/NetzpSearchAdvanced6/src/NetzpSearchAdvanced6.php line 16

  1. <?php declare(strict_types=1);
  2. namespace NetzpSearchAdvanced6;
  3. use NetzpSearchAdvanced6\Components\Installer;
  4. use NetzpSearchAdvanced6\Components\Uninstaller;
  5. use Shopware\Core\Framework\Api\Context\SystemSource;
  6. use Shopware\Core\Framework\Context;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  8. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
  9. use Shopware\Core\Framework\Plugin;
  10. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  11. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  12. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  13. class NetzpSearchAdvanced6 extends Plugin
  14. {
  15.     public function install(InstallContext $context): void
  16.     {
  17.         parent::install($context);
  18.         (new Installer($this->container))->install();
  19.     }
  20.     public function activate(ActivateContext $context): void
  21.     {
  22.         parent::install($context);
  23.         (new Installer($this->container))->activate();
  24.     }
  25.     public function uninstall(UninstallContext $context): void
  26.     {
  27.         parent::uninstall($context);
  28.         $this->removeMigrations();
  29.         (new Uninstaller($this->container))->uninstall($context);
  30.     }
  31.     public function postInstall(InstallContext $installContext): void
  32.     {
  33.         // sometimes the template inheritance does not take effect correctly
  34.         // here the installation date is updated, so it should work
  35.         $repo $this->container->get('plugin.repository');
  36.         $plugin $repo->search(
  37.             (new Criteria())->addFilter(new EqualsFilter('name''NetzpSearchAdvanced6')),
  38.             new Context(new SystemSource())
  39.         )->first();
  40.         if($plugin) {
  41.             $repo->update([
  42.                 [
  43.                     'id'          => $plugin->getId(),
  44.                     'installedAt' => (new \DateTime())->format('Y-m-d H:i:s.v')
  45.                 ]
  46.             ], new Context(new SystemSource()));
  47.         }
  48.     }
  49. }