vendor/shopware/core/System/Language/LanguageLoader.php line 31

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\System\Language;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Doctrine\FetchModeHelper;
  5. use Shopware\Core\Framework\Log\Package;
  6. /**
  7.  * @phpstan-import-type LanguageData from LanguageLoaderInterface
  8.  */
  9. #[Package('core')]
  10. class LanguageLoader implements LanguageLoaderInterface
  11. {
  12.     /**
  13.      * @internal
  14.      */
  15.     public function __construct(private readonly Connection $connection)
  16.     {
  17.     }
  18.     /**
  19.      * @return LanguageData
  20.      */
  21.     public function loadLanguages(): array
  22.     {
  23.         $data $this->connection->createQueryBuilder()
  24.             ->select(['LOWER(HEX(language.id)) AS array_key, LOWER(HEX(language.id)) AS id, locale.code, LOWER(HEX(language.parent_id)) parentId'])
  25.             ->from('language')
  26.             ->leftJoin('language''locale''locale''language.translation_code_id = locale.id')
  27.             ->executeQuery()
  28.             ->fetchAllAssociative();
  29.         return FetchModeHelper::groupUnique($data);
  30.     }
  31. }