custom/plugins/SwagLanguagePack/src/SwagLanguagePack.php line 18

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /*
  3.  * (c) shopware AG <info@shopware.com>
  4.  * For the full copyright and license information, please view the LICENSE
  5.  * file that was distributed with this source code.
  6.  */
  7. namespace Swag\LanguagePack;
  8. use Doctrine\DBAL\Connection;
  9. use Shopware\Core\Framework\Api\Acl\Role\AclRoleDefinition;
  10. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  11. use Shopware\Core\Framework\Plugin;
  12. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  13. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  14. use Swag\LanguagePack\Util\Lifecycle\Lifecycle;
  15. class SwagLanguagePack extends Plugin
  16. {
  17.     public const SUPPORTED_LANGUAGES = [
  18.         'Bahasa Indonesia' => 'id-ID',
  19.         'Bosanski' => 'bs-BA',
  20.         'български език' => 'bg-BG',
  21.         'Čeština' => 'cs-CZ',
  22.         'Dansk' => 'da-DK',
  23.         'Ελληνικά' => 'el-GR',
  24.         'Español' => 'es-ES',
  25.         'Suomi' => 'fi-FI',
  26.         'Français' => 'fr-FR',
  27.         'हिन्दी' => 'hi-IN',
  28.         'Hrvatski' => 'hr-HR',
  29.         'Magyar' => 'hu-HU',
  30.         'Italiano' => 'it-IT',
  31.         '한국어' => 'ko-KR',
  32.         'Latviešu' => 'lv-LV',
  33.         'Nederlands' => 'nl-NL',
  34.         'Norsk' => 'nn-NO',
  35.         'Polski' => 'pl-PL',
  36.         'Português' => 'pt-PT',
  37.         'Română' => 'ro-MD',
  38.         'Русский' => 'ru-RU',
  39.         'Slovenčina' => 'sk-SK',
  40.         'Slovenščina' => 'sl-SI',
  41.         'Srpski' => 'sr-RS',
  42.         'Svenska' => 'sv-SE',
  43.         'Türkçe' => 'tr-TR',
  44.         'Українська' => 'uk-UA',
  45.         'Tiếng Việt Nam' => 'vi-VN',
  46.     ];
  47.     public const BASE_SNIPPET_SET_LOCALES = [
  48.         'bs-BA',
  49.         'bg-BG',
  50.         'cs-CZ',
  51.         'da-DK',
  52.         'el-GR',
  53.         'es-ES',
  54.         'fi-FI',
  55.         'fr-FR',
  56.         'hi-IN',
  57.         'hr-HR',
  58.         'hu-HU',
  59.         'id-ID',
  60.         'it-IT',
  61.         'ko-KR',
  62.         'lv-LV',
  63.         'nl-NL',
  64.         'nn-NO',
  65.         'pl-PL',
  66.         'pt-PT',
  67.         'ro-MD',
  68.         'ru-RU',
  69.         'sk-SK',
  70.         'sl-SI',
  71.         'sr-RS',
  72.         'sv-SE',
  73.         'tr-TR',
  74.         'uk-UA',
  75.         'vi-VN',
  76.     ];
  77.     /**
  78.      * @return array<string, array<string>>
  79.      */
  80.     public function enrichPrivileges(): array
  81.     {
  82.         return [
  83.             AclRoleDefinition::ALL_ROLE_KEY => [
  84.                 'swag_language_pack_language:read',
  85.                 'language:read',
  86.             ],
  87.             'language.editor' => [
  88.                 'swag_language_pack_language:read',
  89.                 'swag_language_pack_language:update',
  90.             ],
  91.         ];
  92.     }
  93.     public function deactivate(DeactivateContext $deactivateContext): void
  94.     {
  95.         parent::deactivate($deactivateContext);
  96.         /** @var Connection $connection */
  97.         $connection $this->container->get(Connection::class);
  98.         /** @var EntityRepositoryInterface $languageRepository */
  99.         $languageRepository $this->container->get('language.repository');
  100.         (new Lifecycle($connection$languageRepository))->deactivate($deactivateContext);
  101.     }
  102.     public function uninstall(UninstallContext $uninstallContext): void
  103.     {
  104.         parent::uninstall($uninstallContext);
  105.         /** @var Connection $connection */
  106.         $connection $this->container->get(Connection::class);
  107.         /** @var EntityRepositoryInterface $languageRepository */
  108.         $languageRepository $this->container->get('language.repository');
  109.         (new Lifecycle($connection$languageRepository))->uninstall($uninstallContext);
  110.     }
  111. }