diff --git a/src/Core/Form/IdentifiableObject/DataProvider/CarrierFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/CarrierFormDataProvider.php index 7e2facfb9ff97..26c254ec2c0d8 100644 --- a/src/Core/Form/IdentifiableObject/DataProvider/CarrierFormDataProvider.php +++ b/src/Core/Form/IdentifiableObject/DataProvider/CarrierFormDataProvider.php @@ -27,6 +27,7 @@ namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; use PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\ZoneByIdChoiceProvider; +use PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider; use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; use PrestaShop\PrestaShop\Core\ConfigurationInterface; use PrestaShop\PrestaShop\Core\Context\ShopContext; @@ -45,7 +46,8 @@ public function __construct( private readonly ShopContext $shopContext, private readonly CurrencyDataProviderInterface $currencyDataProvider, private readonly ConfigurationInterface $configuration, - private readonly ZoneByIdChoiceProvider $zonesChoiceProvider + private readonly ZoneByIdChoiceProvider $zonesChoiceProvider, + private readonly GroupDataProvider $groupDataProvider, ) { } @@ -91,6 +93,7 @@ public function getDefaultData() 'general_settings' => [ 'grade' => 0, 'associated_shops' => $this->shopContext->getAssociatedShopIds(), + 'group_access' => $this->groupDataProvider->getAllGroupIds(), ], ]; } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml b/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml index dadd6a0777c07..ebb84bd859519 100644 --- a/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml +++ b/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml @@ -27,7 +27,10 @@ services: arguments: [ "@=service('prestashop.adapter.legacy.context')" ] prestashop.adapter.data_provider.group: - class: PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider + alias: PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider + deprecated: + package: PrestaShop\PrestaShop + version: 9.0 prestashop.adapter.data_provider.manufacturer: class: PrestaShop\PrestaShop\Adapter\Manufacturer\ManufacturerDataProvider diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/group.yml b/src/PrestaShopBundle/Resources/config/services/adapter/group.yml index 265193a3a4bff..ef3e4503468d9 100644 --- a/src/PrestaShopBundle/Resources/config/services/adapter/group.yml +++ b/src/PrestaShopBundle/Resources/config/services/adapter/group.yml @@ -10,8 +10,13 @@ services: PrestaShop\PrestaShop\Adapter\Customer\Group\Repository\GroupRepository: ~ + PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider: ~ + prestashop.adapter.group.group_data_provider: - class: 'PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider' + alias: 'PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider' + deprecated: + package: PrestaShop\PrestaShop + version: 9.0 prestashop.adapter.feature.group_feature: class: 'PrestaShop\PrestaShop\Adapter\Feature\GroupFeature' diff --git a/tests/Unit/Core/Form/IdentifiableObject/DataProvider/CarrierFormDataProviderTest.php b/tests/Unit/Core/Form/IdentifiableObject/DataProvider/CarrierFormDataProviderTest.php index e4111274b6fe2..6af8828fa316b 100644 --- a/tests/Unit/Core/Form/IdentifiableObject/DataProvider/CarrierFormDataProviderTest.php +++ b/tests/Unit/Core/Form/IdentifiableObject/DataProvider/CarrierFormDataProviderTest.php @@ -28,6 +28,7 @@ use PHPUnit\Framework\TestCase; use PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\ZoneByIdChoiceProvider; +use PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider; use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; use PrestaShop\PrestaShop\Core\ConfigurationInterface; use PrestaShop\PrestaShop\Core\Context\ShopContext; @@ -118,12 +119,15 @@ public function testGetData(): void 'Zone C' => 3, ]); + $groupDataProvider = $this->createMock(GroupDataProvider::class); + $formDataProvider = new CarrierFormDataProvider( $queryBus, $this->createMock(ShopContext::class), $currencyDataProvider, $configuration, - $zonesChoiceProvider + $zonesChoiceProvider, + $groupDataProvider ); $formData = $formDataProvider->getData(42); $this->assertEquals([ @@ -180,17 +184,24 @@ public function testGetDefaultData(): void { $shopContext = $this->createMock(ShopContext::class); $shopContext->method('getAssociatedShopIds')->willReturn([2, 4]); + $groupDataProvider = $this->createMock(GroupDataProvider::class); + $groupDataProvider + ->method('getAllGroupIds') + ->willReturn([1, 2, 3]); + $formDataProvider = new CarrierFormDataProvider( $this->createMock(CommandBusInterface::class), $shopContext, $this->createMock(CurrencyDataProviderInterface::class), $this->createMock(ConfigurationInterface::class), - $this->createMock(ZoneByIdChoiceProvider::class) + $this->createMock(ZoneByIdChoiceProvider::class), + $groupDataProvider ); $this->assertEquals([ 'general_settings' => [ 'grade' => 0, 'associated_shops' => [2, 4], + 'group_access' => [1, 2, 3], ], ], $formDataProvider->getDefaultData()); }