|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | +namespace Magento\Store\Model\Config; |
| 8 | + |
| 9 | +use Magento\Framework\App\State\ReloadProcessorInterface; |
| 10 | +use Magento\Framework\ObjectManagerInterface; |
| 11 | +use Magento\Store\App\Config\Type\Scopes; |
| 12 | +use Magento\Store\Model\GroupRepository; |
| 13 | +use Magento\Store\Model\StoreRepository; |
| 14 | +use Magento\Store\Model\WebsiteRepository; |
| 15 | + |
| 16 | +/** |
| 17 | + * Store module specific reset state part |
| 18 | + */ |
| 19 | +class ReloadDeploymentConfig implements ReloadProcessorInterface |
| 20 | +{ |
| 21 | + |
| 22 | + public function __construct( |
| 23 | + private readonly StoreRepository $storeRepository, |
| 24 | + private readonly WebsiteRepository $websiteRepository, |
| 25 | + private readonly GroupRepository $groupRepository, |
| 26 | + private readonly Scopes $scopes |
| 27 | + ) |
| 28 | + {} |
| 29 | + |
| 30 | + /** |
| 31 | + * Tells the system state to reload itself. |
| 32 | + * |
| 33 | + * @param ObjectManagerInterface $objectManager |
| 34 | + * @return void |
| 35 | + */ |
| 36 | + public function reloadState(): void |
| 37 | + { |
| 38 | + // Note: Magento\Store\Model\StoreManager::reinitStores can't be called because it flushes the caches which |
| 39 | + // we don't want to do because that is already taken care of. Instead, we call the same clean methods that |
| 40 | + // it calls, but we skip cleaning the cache. |
| 41 | + |
| 42 | + $this->storeRepository->clean(); |
| 43 | + $this->websiteRepository->clean(); |
| 44 | + $this->groupRepository->clean(); |
| 45 | + |
| 46 | + $this->scopes->clean(); |
| 47 | + $this->scopes->get(); |
| 48 | + } |
| 49 | +} |
0 commit comments