Commit 996ef69a authored by Piotr Borek's avatar Piotr Borek
Browse files

ecs fix

parent 75dfaf3c
Pipeline #264969256 passed with stages
in 14 minutes and 42 seconds
<?php
declare(strict_types=1);
/*
* Copyright (c) 2021, VillageReach
* Licensed under the Non-Profit Open Software License version 3.0.
......@@ -7,7 +10,6 @@
namespace PcmtRulesBundle\Copier;
use Akeneo\Pim\Enrichment\Component\Product\Builder\EntityWithValuesBuilderInterface;
use Akeneo\Pim\Enrichment\Component\Product\Model\EntityWithValuesInterface;
use Akeneo\Pim\Enrichment\Component\Product\Updater\Copier\AbstractAttributeCopier;
......@@ -20,13 +22,6 @@ class SelectToTextCopier extends AbstractAttributeCopier
/** @var NormalizerInterface */
protected $normalizer;
/**
* @param EntityWithValuesBuilderInterface $entityWithValuesBuilder
* @param AttributeValidatorHelper $attrValidatorHelper
* @param NormalizerInterface $normalizer
* @param array $supportedFromTypes
* @param array $supportedToTypes
*/
public function __construct(
EntityWithValuesBuilderInterface $entityWithValuesBuilder,
AttributeValidatorHelper $attrValidatorHelper,
......@@ -50,7 +45,7 @@ class SelectToTextCopier extends AbstractAttributeCopier
AttributeInterface $fromAttribute,
AttributeInterface $toAttribute,
array $options = []
) {
): void {
$options = $this->resolver->resolve($options);
$fromLocale = $options['from_locale'];
$toLocale = $options['to_locale'];
......@@ -74,26 +69,17 @@ class SelectToTextCopier extends AbstractAttributeCopier
/**
* Copies single value.
*
* @param EntityWithValuesInterface $fromEntityWithValues
* @param EntityWithValuesInterface $toEntityWithValues
* @param AttributeInterface $fromAttribute
* @param AttributeInterface $toAttribute
* @param string $fromLocale
* @param string $toLocale
* @param string $fromScope
* @param string $toScope
*/
protected function copySingleValue(
EntityWithValuesInterface $fromEntityWithValues,
EntityWithValuesInterface $toEntityWithValues,
AttributeInterface $fromAttribute,
AttributeInterface $toAttribute,
$fromLocale,
$toLocale,
$fromScope,
$toScope
) {
string $fromLocale,
string $toLocale,
string $fromScope,
string $toScope
): void {
$fromValue = $fromEntityWithValues->getValue($fromAttribute->getCode(), $fromLocale, $fromScope);
if (null !== $fromValue) {
$standardData = $this->normalizer->normalize($fromValue, 'standard');
......
<?php
declare(strict_types=1);
/*
* Copyright (c) 2021, VillageReach
* Licensed under the Non-Profit Open Software License version 3.0.
......@@ -7,7 +10,6 @@
namespace PcmtRulesBundle\Copier;
use Akeneo\Pim\Enrichment\Component\Product\Builder\EntityWithValuesBuilderInterface;
use Akeneo\Pim\Enrichment\Component\Product\Model\EntityWithValuesInterface;
use Akeneo\Pim\Enrichment\Component\Product\Updater\Copier\AbstractAttributeCopier;
......@@ -20,13 +22,6 @@ class TextToSelectCopier extends AbstractAttributeCopier
/** @var NormalizerInterface */
protected $normalizer;
/**
* @param EntityWithValuesBuilderInterface $entityWithValuesBuilder
* @param AttributeValidatorHelper $attrValidatorHelper
* @param NormalizerInterface $normalizer
* @param array $supportedFromTypes
* @param array $supportedToTypes
*/
public function __construct(
EntityWithValuesBuilderInterface $entityWithValuesBuilder,
AttributeValidatorHelper $attrValidatorHelper,
......@@ -50,7 +45,7 @@ class TextToSelectCopier extends AbstractAttributeCopier
AttributeInterface $fromAttribute,
AttributeInterface $toAttribute,
array $options = []
) {
): void {
$options = $this->resolver->resolve($options);
$fromLocale = $options['from_locale'];
$toLocale = $options['to_locale'];
......@@ -74,33 +69,23 @@ class TextToSelectCopier extends AbstractAttributeCopier
/**
* Copies single value.
*
* @param EntityWithValuesInterface $fromEntityWithValues
* @param EntityWithValuesInterface $toEntityWithValues
* @param AttributeInterface $fromAttribute
* @param AttributeInterface $toAttribute
* @param string $fromLocale
* @param string $toLocale
* @param string $fromScope
* @param string $toScope
*/
protected function copySingleValue(
EntityWithValuesInterface $fromEntityWithValues,
EntityWithValuesInterface $toEntityWithValues,
AttributeInterface $fromAttribute,
AttributeInterface $toAttribute,
$fromLocale,
$toLocale,
$fromScope,
$toScope
) {
string $fromLocale,
string $toLocale,
string $fromScope,
string $toScope
): void {
$fromValue = $fromEntityWithValues->getValue($fromAttribute->getCode(), $fromLocale, $fromScope);
if (null !== $fromValue) {
$standardData = $this->normalizer->normalize($fromValue, 'standard');
if (!$this->checkIfOptionExists($standardData['data'], $toAttribute)) {
throw new \Exception(sprintf('Attribute %s does not have option: %s.',
throw new \Exception(sprintf(
'Attribute %s does not have option: %s.',
$toAttribute->getCode(),
$standardData['data']
));
......@@ -124,6 +109,7 @@ class TextToSelectCopier extends AbstractAttributeCopier
return true;
}
}
return false;
}
......
......@@ -92,7 +92,7 @@ class CorrectAttributeMappingConstraintValidator extends ConstraintValidator
$types = [
'pim_catalog_text',
'pim_catalog_simpleselect'
'pim_catalog_simpleselect',
];
if (in_array($sourceAttribute->getType(), $types) && in_array($destinationAttribute->getType(), $types)) {
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment