vendor/shopware/storefront/Framework/Routing/DomainLoader.php line 64

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Framework\Routing;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Defaults;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Doctrine\FetchModeHelper;
  6. use Shopware\Core\Framework\Log\Package;
  7. use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
  8. /**
  9.  * @phpstan-import-type Domain from AbstractDomainLoader
  10.  */
  11. #[Package('storefront')]
  12. class DomainLoader extends AbstractDomainLoader
  13. {
  14.     /**
  15.      * @internal
  16.      */
  17.     public function __construct(private readonly Connection $connection)
  18.     {
  19.     }
  20.     public function getDecorated(): AbstractDomainLoader
  21.     {
  22.         throw new DecorationPatternException(self::class);
  23.     }
  24.     /**
  25.      * @return array<string, Domain>
  26.      */
  27.     public function load(): array
  28.     {
  29.         $query $this->connection->createQueryBuilder();
  30.         $query->select([
  31.             'CONCAT(TRIM(TRAILING \'/\' FROM domain.url), \'/\') `key`',
  32.             'CONCAT(TRIM(TRAILING \'/\' FROM domain.url), \'/\') url',
  33.             'LOWER(HEX(domain.id)) id',
  34.             'LOWER(HEX(sales_channel.id)) salesChannelId',
  35.             'LOWER(HEX(sales_channel.type_id)) typeId',
  36.             'LOWER(HEX(domain.snippet_set_id)) snippetSetId',
  37.             'LOWER(HEX(domain.currency_id)) currencyId',
  38.             'LOWER(HEX(domain.language_id)) languageId',
  39.             'LOWER(HEX(theme.id)) themeId',
  40.             'sales_channel.maintenance maintenance',
  41.             'sales_channel.maintenance_ip_whitelist maintenanceIpWhitelist',
  42.             'snippet_set.iso as locale',
  43.             'theme.technical_name as themeName',
  44.             'parentTheme.technical_name as parentThemeName',
  45.         ]);
  46.         $query->from('sales_channel');
  47.         $query->innerJoin('sales_channel''sales_channel_domain''domain''domain.sales_channel_id = sales_channel.id');
  48.         $query->innerJoin('domain''snippet_set''snippet_set''snippet_set.id = domain.snippet_set_id');
  49.         $query->leftJoin('sales_channel''theme_sales_channel''theme_sales_channel''sales_channel.id = theme_sales_channel.sales_channel_id');
  50.         $query->leftJoin('theme_sales_channel''theme''theme''theme_sales_channel.theme_id = theme.id');
  51.         $query->leftJoin('theme''theme''parentTheme''theme.parent_theme_id = parentTheme.id');
  52.         $query->where('sales_channel.type_id = UNHEX(:typeId)');
  53.         $query->andWhere('sales_channel.active');
  54.         $query->setParameter('typeId'Defaults::SALES_CHANNEL_TYPE_STOREFRONT);
  55.         /** @var array<string, Domain> $domains */
  56.         $domains FetchModeHelper::groupUnique($query->executeQuery()->fetchAllAssociative());
  57.         return $domains;
  58.     }
  59. }