custom/plugins/SEMKNOX/src/semknoxSearch.php line 26

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. /**
  4.  *
  5.  * @category siteSearch360
  6.  * @package Shopware_Plugins
  7.  * @subpackage Plugin
  8.  * @copyright Copyright (c) 2021, siteSearch360
  9.  * @version $Id$
  10.  * @author siteSearch360
  11.  */
  12. namespace semknox\search;
  13. use Doctrine\DBAL\Connection;
  14. use Shopware\Core\Framework\Plugin;
  15. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  16. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  17. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  18. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  19. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  20. use Shopware\Core\System\SystemConfig\SystemConfigService;
  21. use Symfony\Component\DependencyInjection\ContainerBuilder;
  22. use Symfony\Component\DependencyInjection\ContainerInterface;
  23. use semknox\search\Framework\SemknoxsearchHelper;
  24. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  25. use Symfony\Component\Config\FileLocator;
  26. class semknoxSearch extends Plugin
  27. {
  28.     public const SHOPWARECOMPA_PATH '/Resources/config/compatibility';
  29.     public function build(ContainerBuilder $container): void
  30.     {
  31.         $this->loadServiceXml($container$this->getShopwareVersionServicesFilePath());
  32.         parent::build($container);
  33.     }
  34.     public function uninstall(UninstallContext $uninstallContext): void
  35.     {
  36.         parent::uninstall($uninstallContext);
  37.     }
  38.     private function getShopwareVersionServicesFilePath(): string
  39.     {
  40.         if (SemknoxsearchHelper::shopwareVersionCompare('6.2''<')) {
  41.             return self::SHOPWARECOMPA_PATH '/shopware61';
  42.         } elseif (SemknoxsearchHelper::shopwareVersionCompare('6.3''<')) {
  43.             return self::SHOPWARECOMPA_PATH '/shopware62';
  44.         } elseif (SemknoxsearchHelper::shopwareVersionCompare('6.4''<')) {
  45.             return self::SHOPWARECOMPA_PATH '/shopware63';
  46.         } else {
  47.             return self::SHOPWARECOMPA_PATH '/latest';
  48.         }
  49.     }
  50.     private function loadServiceXml($containerstring $filePath): void
  51.     {
  52.         $loader = new XmlFileLoader(
  53.             $container,
  54.             new FileLocator($this->getPath() . $filePath)
  55.          );
  56.         $loader->load('services.xml');
  57.     }
  58. }