Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecations (#44) #130

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 0 additions & 30 deletions CHANGELOG-2.0.md

This file was deleted.

90 changes: 90 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# UPGRADE FROM `v1.14.0` TO `v2.0.0`

## Codebase

### Use PHP 8 syntax (#128)

#### TL;DR
Refactored the codebase to use PHP 8 syntax.

#### BC Breaks

##### Changed
- [BC] The return type of Webgriffe\SyliusAkeneoPlugin\Converter\ValueConverterInterface#convert() changed from no type to array|bool|int|string
- [BC] The parameter $value of Webgriffe\SyliusAkeneoPlugin\Converter\ValueConverterInterface#convert() changed from no type to a non-contravariant array|bool|int|string
- [BC] The parameter $value of Webgriffe\SyliusAkeneoPlugin\Converter\ValueConverterInterface#convert() changed from no type to array|bool|int|string
- [BC] The parameter $value of Webgriffe\SyliusAkeneoPlugin\Converter\ValueConverter#convert() changed from no type to a non-contravariant array|bool|int|string

### API client replacement (#125)

#### TL;DR
Removed our API Client interface in favor of the Akeneo PHP SDK client.

#### BC Breaks

##### Changed
- [BC] The parameter $apiClient of Webgriffe\SyliusAkeneoPlugin\AttributeOptions\Importer#__construct() changed from Webgriffe\SyliusAkeneoPlugin\AttributeOptions\ApiClientInterface to a non-contravariant Akeneo\Pim\ApiClient\AkeneoPimClientInterface
- [BC] The parameter $apiClient of Webgriffe\SyliusAkeneoPlugin\Converter\UnitMeasurementValueConverter#__construct() changed from Webgriffe\SyliusAkeneoPlugin\MeasurementFamiliesApiClientInterface to a non-contravariant Akeneo\Pim\ApiClient\AkeneoPimClientInterface
- [BC] The parameter $apiClient of Webgriffe\SyliusAkeneoPlugin\Product\Importer#__construct() changed from Webgriffe\SyliusAkeneoPlugin\ApiClientInterface to a non-contravariant Akeneo\Pim\ApiClient\AkeneoPimClientInterface
- [BC] The parameter $apiClient of Webgriffe\SyliusAkeneoPlugin\Product\ProductOptionsResolver#__construct() changed from Webgriffe\SyliusAkeneoPlugin\ApiClientInterface to a non-contravariant Akeneo\Pim\ApiClient\AkeneoPimClientInterface
- [BC] The parameter $apiClient of Webgriffe\SyliusAkeneoPlugin\ValueHandler\FileAttributeValueHandler#__construct() changed from Webgriffe\SyliusAkeneoPlugin\ApiClientInterface to a non-contravariant Akeneo\Pim\ApiClient\AkeneoPimClientInterface
- [BC] The parameter $apiClient of Webgriffe\SyliusAkeneoPlugin\ValueHandler\ImageValueHandler#__construct() changed from Webgriffe\SyliusAkeneoPlugin\ApiClientInterface to a non-contravariant Akeneo\Pim\ApiClient\AkeneoPimClientInterface
- [BC] The parameter $apiClient of Webgriffe\SyliusAkeneoPlugin\ValueHandler\ProductOptionValueHandler#__construct() changed from Webgriffe\SyliusAkeneoPlugin\ApiClientInterface to a non-contravariant Akeneo\Pim\ApiClient\AkeneoPimClientInterface
- [BC] The parameter $apiClient of Webgriffe\SyliusAkeneoPlugin\ProductAssociations\Importer#__construct() changed from Webgriffe\SyliusAkeneoPlugin\ApiClientInterface to a non-contravariant Akeneo\Pim\ApiClient\AkeneoPimClientInterface

##### Removed
- [BC] Class Webgriffe\SyliusAkeneoPlugin\AttributeOptions\ApiClientInterface has been deleted
- [BC] Class Webgriffe\SyliusAkeneoPlugin\ApiClientInterface has been deleted
- [BC] Class Webgriffe\SyliusAkeneoPlugin\MeasurementFamiliesApiClientInterface has been deleted
- [BC] Class Webgriffe\SyliusAkeneoPlugin\ApiClient has been deleted
- [BC] Class Webgriffe\SyliusAkeneoPlugin\FamilyAwareApiClientInterface has been deleted

### Remove deprecations (#130)

#### TL;DR
Removed all deprecations of the v1.x releases.

#### BC Breaks

##### Changed
- [BC] The number of required arguments for Webgriffe\SyliusAkeneoPlugin\Controller\ProductEnqueueController#__construct() increased from 3 to 4
- [BC] The parameter $translator of Webgriffe\SyliusAkeneoPlugin\Controller\ProductEnqueueController#__construct() changed from Symfony\Contracts\Translation\TranslatorInterface|null to a non-contravariant Symfony\Contracts\Translation\TranslatorInterface
- [BC] The number of required arguments for Webgriffe\SyliusAkeneoPlugin\Converter\ValueConverter#__construct() increased from 0 to 1
- [BC] The parameter $translator of Webgriffe\SyliusAkeneoPlugin\Converter\ValueConverter#__construct() changed from Symfony\Contracts\Translation\TranslatorInterface|null to a non-contravariant Symfony\Contracts\Translation\TranslatorInterface
- [BC] The number of required arguments for Webgriffe\SyliusAkeneoPlugin\Product\Importer#__construct() increased from 12 to 13
- [BC] The parameter $variantStatusResolver of Webgriffe\SyliusAkeneoPlugin\Product\Importer#__construct() changed from Webgriffe\SyliusAkeneoPlugin\Product\StatusResolverInterface|null to a non-contravariant Webgriffe\SyliusAkeneoPlugin\Product\StatusResolverInterface
- [BC] The number of required arguments for Webgriffe\SyliusAkeneoPlugin\ValueHandler\AttributeValueHandler#__construct() increased from 3 to 4
- [BC] The parameter $valueConverter of Webgriffe\SyliusAkeneoPlugin\ValueHandler\AttributeValueHandler#__construct() changed from Webgriffe\SyliusAkeneoPlugin\Converter\ValueConverterInterface|null to a non-contravariant Webgriffe\SyliusAkeneoPlugin\Converter\ValueConverterInterface
- [BC] The number of required arguments for Webgriffe\SyliusAkeneoPlugin\ValueHandler\ChannelPricingValueHandler#__construct() increased from 4 to 5
- [BC] The parameter $propertyAccessor of Webgriffe\SyliusAkeneoPlugin\ValueHandler\ChannelPricingValueHandler#__construct() changed from Symfony\Component\PropertyAccess\PropertyAccessorInterface|null to a non-contravariant Symfony\Component\PropertyAccess\PropertyAccessorInterface
- [BC] The number of required arguments for Webgriffe\SyliusAkeneoPlugin\ValueHandler\ProductOptionValueHandler#__construct() increased from 5 to 7
- [BC] The parameter $translationLocaleProvider of Webgriffe\SyliusAkeneoPlugin\ValueHandler\ProductOptionValueHandler#__construct() changed from Sylius\Component\Resource\Translation\Provider\TranslationLocaleProviderInterface|null to a non-contravariant Sylius\Component\Resource\Translation\Provider\TranslationLocaleProviderInterface
- [BC] The parameter $translator of Webgriffe\SyliusAkeneoPlugin\ValueHandler\ProductOptionValueHandler#__construct() changed from Symfony\Contracts\Translation\TranslatorInterface|null to a non-contravariant Symfony\Contracts\Translation\TranslatorInterface

##### Removed
- [BC] Property Webgriffe\SyliusAkeneoPlugin\DependencyInjection\WebgriffeSyliusAkeneoExtension::$valueHandlersTypesDefinitions was removed
- [BC] Removed the service `webgriffe_sylius_akeneo_plugin.repository.cleanable_queue_item`, use the `webgriffe_sylius_akeneo.repository.cleanable_queue_item` instead.
- [BC] Removed the service `webgriffe_sylius_akeneo_plugin.controller.product_enqueue_controller`, use the `webgriffe_sylius_akeneo.controller.product_enqueue_controller` instead.
- [BC] Removed the resource `webgriffe_sylius_akeneo_plugin.queue_item` use the `webgriffe_sylius_akeneo.queue_item` instead.

### Test changes

#### TL;DR
Edits made on test classes during the previous changes.

#### BC Breaks

##### Removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findProductModel() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findFamilyVariant() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findAttribute() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findProduct() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findAttributeOption() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#downloadFile() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findProductsModifiedSince() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findAllAttributeOptions() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findAllAttributes() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findAllFamilies() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#findFamily() was removed
- [BC] Method Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock#getMeasurementFamilies() was removed
- [BC] These ancestors of Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble\ApiClientMock have been removed: ["Webgriffe\\SyliusAkeneoPlugin\\ApiClientInterface","Webgriffe\\SyliusAkeneoPlugin\\AttributeOptions\\ApiClientInterface","Webgriffe\\SyliusAkeneoPlugin\\FamilyAwareApiClientInterface","Webgriffe\\SyliusAkeneoPlugin\\MeasurementFamiliesApiClientInterface"]
17 changes: 1 addition & 16 deletions spec/Converter/ValueConverterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function let(
]
);

$this->beConstructedWith();
$this->beConstructedWith($translator);
}

function it_is_initializable()
Expand Down Expand Up @@ -91,24 +91,9 @@ function it_throws_exception_during_convert_when_value_contains_amount_key_and_n
]);
}

function it_converts_metric_value_from_akeneo_to_text_value_not_translated_when_translator_is_not_injected(
AttributeInterface $textAttribute
) {
$this->convert(
$textAttribute,
[
'amount' => 23.0000,
'unit' => 'INCH',
],
'it'
)->shouldReturn('23 INCH');
}

function it_converts_metric_value_from_akeneo_to_text_value_translated_when_translator_is_injected(
TranslatorInterface $translator,
AttributeInterface $textAttribute
) {
$this->beConstructedWith($translator);
$this->convert(
$textAttribute,
[
Expand Down
25 changes: 1 addition & 24 deletions src/Controller/ProductEnqueueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,16 @@

final class ProductEnqueueController extends AbstractController
{
private ?TranslatorInterface $translator;

/**
* ProductEnqueueController constructor.
*/
public function __construct(
private QueueItemRepositoryInterface $queueItemRepository,
private ProductRepositoryInterface $productRepository,
private UrlGeneratorInterface $urlGenerator,
TranslatorInterface $translator = null
private TranslatorInterface $translator
) {
if ($translator === null) {
trigger_deprecation(
'webgriffe/sylius-akeneo-plugin',
'1.12',
'Not passing a translator to "%s" is deprecated and will be removed in %s.',
self::class,
'2.0'
);
}
$this->translator = $translator;
}

public function enqueueAction(int $productId): Response
{
if ($this->translator === null) {
/**
* @psalm-suppress DeprecatedMethod
*/
$translator = $this->get('translator');
Assert::isInstanceOf($translator, TranslatorInterface::class);
$this->translator = $translator;
}
/** @var ProductInterface|null $product */
$product = $this->productRepository->find($productId);
if ($product === null) {
Expand Down
20 changes: 1 addition & 19 deletions src/Converter/ValueConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,9 @@

final class ValueConverter implements ValueConverterInterface
{
private ?TranslatorInterface $translator;

/**
* ValueConverter constructor.
*/
public function __construct(
TranslatorInterface $translator = null
private TranslatorInterface $translator
) {
if ($translator === null) {
trigger_deprecation(
'webgriffe/sylius-akeneo-plugin',
'1.8',
'Not passing a translator to "%s" is deprecated and will be removed in %s.',
self::class,
'2.0'
);
}
$this->translator = $translator;
}

public function convert(AttributeInterface $attribute, array|bool|int|string $value, string $localeCode): array|bool|int|string
Expand All @@ -44,9 +29,6 @@ public function convert(AttributeInterface $attribute, array|bool|int|string $va
throw new \LogicException('Unit key not found');
}
$unit = (string) $value['unit'];
if ($this->translator === null) {
return $floatAmount . ' ' . $unit;
}

return $this->translator->trans('webgriffe_sylius_akeneo.ui.metric_amount_unit', ['unit' => $unit, 'amount' => $floatAmount], null, $localeCode);
}
Expand Down
76 changes: 0 additions & 76 deletions src/DependencyInjection/WebgriffeSyliusAkeneoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,79 +30,6 @@ final class WebgriffeSyliusAkeneoExtension extends AbstractResourceExtension imp

private const RECONCILER_TAG = 'webgriffe_sylius_akeneo.reconciler';

/**
* @var array
*
* @deprecated Do not use anymore. Use $valueHandlersTypesDefinitionsPrivate instead.
*/
public static $valueHandlersTypesDefinitions = [
'channel_pricing' => [
'class' => ChannelPricingValueHandler::class,
'arguments' => [
'sylius.factory.channel_pricing',
'sylius.repository.channel',
'sylius.repository.currency',
],
],
'generic_property' => [
'class' => GenericPropertyValueHandler::class,
'arguments' => [
'property_accessor',
],
],
'image' => [
'class' => ImageValueHandler::class,
'arguments' => [
'sylius.factory.product_image',
'sylius.repository.product_image',
'webgriffe_sylius_akeneo.api_client',
],
],
'immutable_slug' => [
'class' => ImmutableSlugValueHandler::class,
'arguments' => [
'webgriffe_sylius_akeneo.slugify',
'sylius.factory.product_translation',
'sylius.translation_locale_provider.admin',
'sylius.repository.product_translation',
],
],
'product_option' => [
'class' => ProductOptionValueHandler::class,
'arguments' => [
'webgriffe_sylius_akeneo.api_client',
'sylius.repository.product_option',
'sylius.factory.product_option_value',
'sylius.factory.product_option_value_translation',
'sylius.repository.product_option_value',
],
],
'translatable_property' => [
'class' => TranslatablePropertyValueHandler::class,
'arguments' => [
'property_accessor',
'sylius.factory.product_translation',
'sylius.factory.product_variant_translation',
'sylius.translation_locale_provider.admin',
],
],
'generic_attribute' => [
'class' => AttributeValueHandler::class,
'arguments' => [
'sylius.repository.product_attribute',
'sylius.factory.product_attribute_value',
'sylius.translation_locale_provider.admin',
],
],
'file_attribute' => [
'class' => FileAttributeValueHandler::class,
'arguments' => [
'webgriffe_sylius_akeneo.api_client',
'filesystem',
],
],
];

/** @var array<string, array{class: string, arguments: string[]}> */
private static array $valueHandlersTypesDefinitionsPrivate = [
'channel_pricing' => [
Expand Down Expand Up @@ -194,9 +121,6 @@ public function load(array $config, ContainerBuilder $container): void
Assert::isArray($config['resources']);

$this->registerResources('webgriffe_sylius_akeneo', 'doctrine/orm', $config['resources'], $container);
// The following registers plugin resources again with a different prefix. This is only for BC compatibility
// and could be removed in 2.x.
$this->registerResources('webgriffe_sylius_akeneo_plugin', 'doctrine/orm', $config['resources'], $container);
$this->registerApiClientParameters($config['api_client'], $container);

$loader->load('services.xml');
Expand Down