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

  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\EntityRepository;
  11. use Shopware\Core\Framework\Plugin;
  12. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  13. use Shopware\Core\System\Language\LanguageCollection;
  14. use Swag\LanguagePack\Util\Lifecycle\Lifecycle;
  15. use Symfony\Component\DependencyInjection\ContainerInterface;
  16. class SwagLanguagePack extends Plugin
  17. {
  18.     public const SUPPORTED_LANGUAGES = [
  19.         'Bahasa Indonesia' => 'id-ID',
  20.         'Bosanski' => 'bs-BA',
  21.         'български език' => 'bg-BG',
  22.         'Čeština' => 'cs-CZ',
  23.         'Dansk' => 'da-DK',
  24.         'Ελληνικά' => 'el-GR',
  25.         'English (US)' => 'en-US',
  26.         'Español' => 'es-ES',
  27.         'Suomi' => 'fi-FI',
  28.         'Français' => 'fr-FR',
  29.         'हिन्दी' => 'hi-IN',
  30.         'Hrvatski' => 'hr-HR',
  31.         'Magyar' => 'hu-HU',
  32.         'Italiano' => 'it-IT',
  33.         '한국어' => 'ko-KR',
  34.         'Latviešu' => 'lv-LV',
  35.         'Nederlands' => 'nl-NL',
  36.         'Norsk' => 'nn-NO',
  37.         'Polski' => 'pl-PL',
  38.         'Português' => 'pt-PT',
  39.         'Română' => 'ro-RO',
  40.         'Русский' => 'ru-RU',
  41.         'Slovenčina' => 'sk-SK',
  42.         'Slovenščina' => 'sl-SI',
  43.         'Srpski' => 'sr-RS',
  44.         'Svenska' => 'sv-SE',
  45.         'Türkçe' => 'tr-TR',
  46.         'Українська' => 'uk-UA',
  47.         'Tiếng Việt Nam' => 'vi-VN',
  48.     ];
  49.     public const BASE_SNIPPET_SET_LOCALES = [
  50.         'bs-BA',
  51.         'bg-BG',
  52.         'cs-CZ',
  53.         'da-DK',
  54.         'el-GR',
  55.         'en-US',
  56.         'es-ES',
  57.         'fi-FI',
  58.         'fr-FR',
  59.         'hi-IN',
  60.         'hr-HR',
  61.         'hu-HU',
  62.         'id-ID',
  63.         'it-IT',
  64.         'ko-KR',
  65.         'lv-LV',
  66.         'nl-NL',
  67.         'nn-NO',
  68.         'pl-PL',
  69.         'pt-PT',
  70.         'ro-RO',
  71.         'ru-RU',
  72.         'sk-SK',
  73.         'sl-SI',
  74.         'sr-RS',
  75.         'sv-SE',
  76.         'tr-TR',
  77.         'uk-UA',
  78.         'vi-VN',
  79.     ];
  80.     /**
  81.      * @return array<string, array<string>>
  82.      */
  83.     public function enrichPrivileges(): array
  84.     {
  85.         return [
  86.             AclRoleDefinition::ALL_ROLE_KEY => [
  87.                 'swag_language_pack_language:read',
  88.                 'language:read',
  89.             ],
  90.             'language.editor' => [
  91.                 'swag_language_pack_language:read',
  92.                 'swag_language_pack_language:update',
  93.             ],
  94.         ];
  95.     }
  96.     public function uninstall(UninstallContext $uninstallContext): void
  97.     {
  98.         parent::uninstall($uninstallContext);
  99.         \assert($this->container instanceof ContainerInterface'Container is not set yet, please call setContainer() before calling boot(), see `src/Core/Kernel.php:186`.');
  100.         /** @var Connection $connection */
  101.         $connection $this->container->get(Connection::class);
  102.         /** @var EntityRepository<LanguageCollection> $languageRepository */
  103.         $languageRepository $this->container->get('language.repository');
  104.         (new Lifecycle($connection$languageRepository))->uninstall($uninstallContext);
  105.     }
  106. }