diff --git a/src/Completeness/Checker/TextCollectionCompleteChecker.php b/src/Completeness/Checker/TextCollectionCompleteChecker.php deleted file mode 100644 index 18940bb..0000000 --- a/src/Completeness/Checker/TextCollectionCompleteChecker.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright 2016 Akeneo SAS (http://www.akeneo.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -class TextCollectionCompleteChecker implements ValueCompleteCheckerInterface -{ - /** - * {@inheritdoc} - */ - public function isComplete( - ValueInterface $value, - ChannelInterface $channel = null, - LocaleInterface $locale = null - ) { - if (null !== $value->getScope() && $channel->getCode() !== $value->getScope()) { - return false; - } - - if (null !== $value->getLocale() && $locale->getCode() !== $value->getLocale()) { - return false; - } - - $collection = $value->getData(); - - return null !== $collection && count($collection) > 0; - } - - /** - * {@inheritdoc} - */ - public function supportsValue( - ValueInterface $value, - ChannelInterface $channel, - LocaleInterface $locale - ) { - return ExtendedAttributeTypes::TEXT_COLLECTION === $value->getAttribute()->getType(); - } -} diff --git a/src/Factory/Value/TextCollectionValueFactory.php b/src/Factory/Value/TextCollectionValueFactory.php deleted file mode 100644 index b4a876f..0000000 --- a/src/Factory/Value/TextCollectionValueFactory.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @copyright 2017 Akeneo SAS (http://www.akeneo.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -class TextCollectionValueFactory implements ValueFactoryInterface -{ - /** @var string */ - protected $productValueClass; - - /** @var string */ - protected $supportedAttributeTypes; - - /** - * @param string $productValueClass - * @param string $supportedAttributeTypes - */ - public function __construct($productValueClass, $supportedAttributeTypes) - { - $this->productValueClass = $productValueClass; - $this->supportedAttributeTypes = $supportedAttributeTypes; - } - - /** - * {@inheritdoc} - */ - public function create(AttributeInterface $attribute, $channelCode, $localeCode, $data) - { - $this->checkData($attribute, $data); - - if (null !== $data) { - $data = $this->convertData($attribute, $data); - } - - $value = new $this->productValueClass($attribute, $channelCode, $localeCode, $data); - - return $value; - } - - /** - * {@inheritdoc} - */ - public function supports($attributeType) - { - return $attributeType === $this->supportedAttributeTypes; - } - - /** - * @param AttributeInterface $attribute - * @param mixed $data - * - * @throws InvalidPropertyTypeException - */ - protected function checkData(AttributeInterface $attribute, $data) - { - if (null === $data) { - return; - } - - if (!is_array($data)) { - throw InvalidPropertyTypeException::arrayExpected( - $attribute->getCode(), - static::class, - $data - ); - } - } - - /** - * @param AttributeInterface $attribute - * @param mixed $data - * - * @return mixed - */ - protected function convertData(AttributeInterface $attribute, $data) - { - if (is_string($data) && '' === trim($data)) { - $data = null; - } - - if (AttributeTypes::BOOLEAN === $attribute->getType() && - (1 === $data || '1' === $data || 0 === $data || '0' === $data) - ) { - $data = boolval($data); - } - - return $data; - } -} diff --git a/src/Model/TextCollectionValue.php b/src/Model/TextCollectionValue.php deleted file mode 100644 index 4377179..0000000 --- a/src/Model/TextCollectionValue.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright 2017 Akeneo SAS (http://www.akeneo.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -class TextCollectionValue extends AbstractValue implements ValueInterface -{ - /** @var string[] */ - protected $data; - - /** - * @param AttributeInterface $attribute - * @param string $channel - * @param string $locale - * @param mixed $data - */ - public function __construct(AttributeInterface $attribute, $channel, $locale, $data) - { - $this->setAttribute($attribute); - $this->setScope($channel); - $this->setLocale($locale); - - $this->data = $data; - } - - /** - * @return string[] - */ - public function getData() - { - return $this->data; - } - - /** - * @param string $item - */ - public function removeItem(string $item) - { - $data = array_filter($this->data, function ($value) use ($item) { - return $value !== $item; - }); - $this->data = array_values($data); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return implode(', ', $this->data); - } -} diff --git a/src/Normalizer/Indexing/Value/TextCollectionNormalizer.php b/src/Normalizer/Indexing/Value/TextCollectionNormalizer.php deleted file mode 100644 index 8762b0a..0000000 --- a/src/Normalizer/Indexing/Value/TextCollectionNormalizer.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright 2017 Akeneo SAS (http://www.akeneo.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -class TextCollectionNormalizer extends AbstractProductValueNormalizer implements NormalizerInterface -{ - /** - * {@inheritdoc} - */ - public function supportsNormalization($data, $format = null) - { - return $data instanceof TextCollectionValue && ( - $format === ProductNormalizer::INDEXING_FORMAT_PRODUCT_INDEX || - $format === ProductModel\ProductModelNormalizer::INDEXING_FORMAT_PRODUCT_MODEL_INDEX || - $format === ProductAndProductModel\ProductModelNormalizer::INDEXING_FORMAT_PRODUCT_AND_MODEL_INDEX - ); - } - - /** - * {@inheritdoc} - */ - protected function getNormalizedData(ValueInterface $value) - { - return $value->getData(); - } -} diff --git a/src/ArrayConverter/FlatToStandard/Product/ValueConverter/TextCollectionConverter.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/ArrayConverter/FlatToStandard/Product/ValueConverter/TextCollectionConverter.php old mode 100644 new mode 100755 similarity index 62% rename from src/ArrayConverter/FlatToStandard/Product/ValueConverter/TextCollectionConverter.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/ArrayConverter/FlatToStandard/Product/ValueConverter/TextCollectionConverter.php index 3e2fe51..e022821 --- a/src/ArrayConverter/FlatToStandard/Product/ValueConverter/TextCollectionConverter.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/ArrayConverter/FlatToStandard/Product/ValueConverter/TextCollectionConverter.php @@ -2,8 +2,10 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\ArrayConverter\FlatToStandard\Product\ValueConverter; -use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\TextCollectionType; -use Pim\Component\Connector\ArrayConverter\FlatToStandard\Product\ValueConverter\ValueConverterInterface; +use Akeneo\Pim\Enrichment\Component\Product\Connector\ArrayConverter\FlatToStandard\FieldSplitter; +use Akeneo\Pim\Enrichment\Component\Product\Connector\ArrayConverter\FlatToStandard\ValueConverter\AbstractValueConverter; + +//use Pim\Component\Connector\ArrayConverter\FlatToStandard\Product\ValueConverter\ValueConverterInterface; /** * Converts a text collection value from Akeneo PIM flat format to Akeneo PIM standard format @@ -31,25 +33,17 @@ * @copyright 2017 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class TextCollectionConverter implements ValueConverterInterface +class TextCollectionConverter extends AbstractValueConverter { - /** @var string[] */ - protected $supportedFieldTypes; - /** - * @param string[] $supportedFieldTypes + * @param FieldSplitter $fieldSplitter + * @param array $supportedFieldType */ - public function __construct(array $supportedFieldTypes) + public function __construct(FieldSplitter $fieldSplitter, array $supportedFieldType) { - $this->supportedFieldTypes = $supportedFieldTypes; - } + parent::__construct($fieldSplitter); - /** - * {@inheritdoc} - */ - public function supportsField($attributeType) - { - return in_array($attributeType, $this->supportedFieldTypes); + $this->supportedFieldType = $supportedFieldType; } /** @@ -65,7 +59,7 @@ public function convert(array $attributeFieldInfo, $value) $attributeFieldInfo['attribute']->getCode() => [[ 'locale' => $attributeFieldInfo['locale_code'], 'scope' => $attributeFieldInfo['scope_code'], - 'data' => explode(TextCollectionType::FLAT_SEPARATOR, $value), + 'data' => $this->fieldSplitter->splitCollection($value) ]], ]; } diff --git a/src/ArrayConverter/StandardToFlat/Product/ValueConverter/TextCollectionConverter.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/ArrayConverter/StandardToFlat/Product/ValueConverter/TextCollectionConverter.php old mode 100644 new mode 100755 similarity index 78% rename from src/ArrayConverter/StandardToFlat/Product/ValueConverter/TextCollectionConverter.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/ArrayConverter/StandardToFlat/Product/ValueConverter/TextCollectionConverter.php index 06cbc52..2fef5fc --- a/src/ArrayConverter/StandardToFlat/Product/ValueConverter/TextCollectionConverter.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/ArrayConverter/StandardToFlat/Product/ValueConverter/TextCollectionConverter.php @@ -2,9 +2,10 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\ArrayConverter\StandardToFlat\Product\ValueConverter; +use Akeneo\Pim\Enrichment\Component\Product\Connector\ArrayConverter\StandardToFlat\Product\ValueConverter\AbstractValueConverter; use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\TextCollectionType; -use Pim\Component\Connector\ArrayConverter\StandardToFlat\Product\ValueConverter\AbstractValueConverter; -use Pim\Component\Connector\ArrayConverter\StandardToFlat\Product\ValueConverter\ValueConverterInterface; +//use Pim\Component\Connector\ArrayConverter\StandardToFlat\Product\ValueConverter\AbstractValueConverter; +//use Pim\Component\Connector\ArrayConverter\StandardToFlat\Product\ValueConverter\ValueConverterInterface; /** * Converts a text collection value from Akeneo PIM standard format to Akeneo PIM flat format @@ -32,7 +33,7 @@ * @copyright 2017 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class TextCollectionConverter extends AbstractValueConverter implements ValueConverterInterface +class TextCollectionConverter extends AbstractValueConverter { /** * Converts a value diff --git a/src/AttributeType/ExtendedAttributeTypes.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/AttributeType/ExtendedAttributeTypes.php old mode 100644 new mode 100755 similarity index 87% rename from src/AttributeType/ExtendedAttributeTypes.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/AttributeType/ExtendedAttributeTypes.php index 6421e71..a11c20a --- a/src/AttributeType/ExtendedAttributeTypes.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/AttributeType/ExtendedAttributeTypes.php @@ -1,7 +1,6 @@ load('array_converters.yml'); $loader->load('attribute_types.yml'); $loader->load('comparators.yml'); - $loader->load('completeness.yml'); + $loader->load('completeness_mask_generators.yml'); $loader->load('denormalizers.yml'); + $loader->load('entities.yml'); $loader->load('form_types.yml'); + $loader->load('product_value_factories.yml'); $loader->load('providers.yml'); - $loader->load('updaters.yml'); - $loader->load('validators.yml'); - - $loader->load('entities.yml'); - $loader->load('factories.yml'); $loader->load('query_builders.yml'); - if (class_exists('PimEnterprise\Bundle\WorkflowBundle\PimEnterpriseWorkflowBundle')) { + if (class_exists('Akeneo\Pim\WorkOrganization\Workflow\Bundle\AkeneoPimWorkflowBundle')) { $loader->load('query_builders_ee.yml'); } + $loader->load('updaters.yml'); + $loader->load('validators.yml'); + $loader->load('datagrid/attribute_types.yml'); $loader->load('datagrid/filters.yml'); diff --git a/src/Elasticsearch/Filter/Attribute/ProductProposalTextCollectionFilter.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Elasticsearch/Filter/Attribute/ProductProposalTextCollectionFilter.php old mode 100644 new mode 100755 similarity index 76% rename from src/Elasticsearch/Filter/Attribute/ProductProposalTextCollectionFilter.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Elasticsearch/Filter/Attribute/ProductProposalTextCollectionFilter.php index 3500552..901deb8 --- a/src/Elasticsearch/Filter/Attribute/ProductProposalTextCollectionFilter.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Elasticsearch/Filter/Attribute/ProductProposalTextCollectionFilter.php @@ -2,13 +2,23 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Elasticsearch\Filter\Attribute; -use Akeneo\Component\StorageUtils\Exception\InvalidPropertyTypeException; -use Pim\Component\Catalog\Exception\InvalidOperatorException; -use Pim\Component\Catalog\Model\AttributeInterface; -use Pim\Component\Catalog\Query\Filter\AttributeFilterInterface; -use Pim\Component\Catalog\Query\Filter\Operators; -use PimEnterprise\Bundle\WorkflowBundle\Elasticsearch\Filter\Attribute\AbstractAttributeFilter; -use PimEnterprise\Bundle\WorkflowBundle\Elasticsearch\Filter\Attribute\ProposalAttributePathResolver; +//use Akeneo\Component\StorageUtils\Exception\InvalidPropertyTypeException; +//use Pim\Component\Catalog\Exception\InvalidOperatorException; +//use Pim\Component\Catalog\Model\AttributeInterface; +//use Pim\Component\Catalog\Query\Filter\AttributeFilterInterface; +//use Pim\Component\Catalog\Query\Filter\Operators; +//use PimEnterprise\Bundle\WorkflowBundle\Elasticsearch\Filter\Attribute\AbstractAttributeFilter; +//use PimEnterprise\Bundle\WorkflowBundle\Elasticsearch\Filter\Attribute\ProposalAttributePathResolver; +//use Akeneo\Pim\Enrichment\Bundle\Elasticsearch\Filter\Attribute\AbstractAttributeFilter; +use Akeneo\Pim\Enrichment\Component\Product\Exception\InvalidOperatorException; +use Akeneo\Pim\Enrichment\Component\Product\Query\Filter\Operators; +use Akeneo\Pim\Enrichment\Component\Product\Query\Filter\AttributeFilterInterface; +use Akeneo\Pim\Structure\Component\Model\AttributeInterface; +use Akeneo\Pim\WorkOrganization\Workflow\Bundle\Elasticsearch\Filter\Attribute\AbstractAttributeFilter; +use Akeneo\Pim\WorkOrganization\Workflow\Bundle\Elasticsearch\Filter\Attribute\ProposalAttributePathResolver; +use Akeneo\Tool\Component\StorageUtils\Exception\InvalidPropertyTypeException; + +//use Akeneo\Pim\WorkOrganization\Workflow\Bundle\Elasticsearch\Filter\Attribute\AbstractAttributeFilter; /** * @author Mathias METAYER @@ -51,7 +61,7 @@ public function addAttributeFilter( $this->checkValue($attribute, $value); } - $attributePaths = $this->attributePathResolver->getAttributePaths($attribute, $locale, $channel); + $attributePaths = $this->attributePathResolver->getAttributePaths($attribute); switch ($operator) { case Operators::CONTAINS: diff --git a/src/Elasticsearch/Filter/Attribute/TextCollectionFilter.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Elasticsearch/Filter/Attribute/TextCollectionFilter.php old mode 100644 new mode 100755 similarity index 67% rename from src/Elasticsearch/Filter/Attribute/TextCollectionFilter.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Elasticsearch/Filter/Attribute/TextCollectionFilter.php index cfcb1fa..15525bb --- a/src/Elasticsearch/Filter/Attribute/TextCollectionFilter.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Elasticsearch/Filter/Attribute/TextCollectionFilter.php @@ -2,20 +2,27 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Elasticsearch\Filter\Attribute; -use Akeneo\Component\StorageUtils\Exception\InvalidPropertyTypeException; -use Pim\Bundle\CatalogBundle\Elasticsearch\Filter\Attribute\AbstractAttributeFilter; -use Pim\Component\Catalog\Exception\InvalidOperatorException; -use Pim\Component\Catalog\Model\AttributeInterface; -use Pim\Component\Catalog\Query\Filter\AttributeFilterInterface; -use Pim\Component\Catalog\Query\Filter\Operators; -use Pim\Component\Catalog\Validator\AttributeValidatorHelper; +//use Akeneo\Component\StorageUtils\Exception\InvalidPropertyTypeException; +//use Pim\Bundle\CatalogBundle\Elasticsearch\Filter\Attribute\AbstractAttributeFilter; +//use Pim\Component\Catalog\Exception\InvalidOperatorException; +//use Pim\Component\Catalog\Model\AttributeInterface; +//use Pim\Component\Catalog\Query\Filter\AttributeFilterInterface; +//use Pim\Component\Catalog\Query\Filter\Operators; +//use Pim\Component\Catalog\Validator\AttributeValidatorHelper; +use Akeneo\Pim\Enrichment\Bundle\Elasticsearch\Filter\Attribute\AbstractAttributeFilter; +use Akeneo\Pim\Enrichment\Component\Product\Exception\InvalidOperatorException; +use Akeneo\Pim\Enrichment\Component\Product\Query\Filter\Operators; +use Akeneo\Pim\Enrichment\Component\Product\Validator\AttributeValidatorHelper; +use Akeneo\Pim\Structure\Component\Model\AttributeInterface; +use Akeneo\Tool\Component\Elasticsearch\QueryString; +use Akeneo\Tool\Component\StorageUtils\Exception\InvalidPropertyTypeException; /** * @author Mathias METAYER * @copyright 2018 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class TextCollectionFilter extends AbstractAttributeFilter implements AttributeFilterInterface +class TextCollectionFilter extends AbstractAttributeFilter { /** * @param AttributeValidatorHelper $attrValidatorHelper @@ -55,20 +62,26 @@ public function addAttributeFilter( $attributePath = $this->getAttributePath($attribute, $locale, $channel); + /** + * @todo probably have to change the generated queries? + * @see \Akeneo\Pim\Enrichment\Bundle\Elasticsearch\Filter\Attribute\TextAreaFilter for examples + */ switch ($operator) { case Operators::CONTAINS: $clause = [ - 'term' => [ - $attributePath => $value, + 'wildcard' => [ + $attributePath => '*' . $value . '*', ], +// 'default_field' => $attributePath, +// 'query' => '*' . QueryString::escapeValue($value) . '*', ]; $this->searchQueryBuilder->addFilter($clause); break; case Operators::DOES_NOT_CONTAIN: $mustNotClause = [ - 'term' => [ - $attributePath => $value, + 'wildcard' => [ + $attributePath => '*' . $value . '*', ], ]; $filterClause = [ diff --git a/src/Pim/Bundle/ExtendedAttributeTypeBundle/Factory/Value/TextCollectionValueFactory.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Factory/Value/TextCollectionValueFactory.php new file mode 100755 index 0000000..8182078 --- /dev/null +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Factory/Value/TextCollectionValueFactory.php @@ -0,0 +1,159 @@ + + * @copyright 2017 Akeneo SAS (http://www.akeneo.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +class TextCollectionValueFactory implements ValueFactory +{ + public function createWithoutCheckingData(Attribute $attribute, ?string $channelCode, ?string $localeCode, $data): ValueInterface + { + sort($data); + $attributeCode = $attribute->code(); + + if ($attribute->isLocalizableAndScopable()) { + return ScalarValue::scopableLocalizableValue($attributeCode, $data, $channelCode, $localeCode); + } + + if ($attribute->isScopable()) { + return ScalarValue::scopableValue($attributeCode, $data, $channelCode); + } + + if ($attribute->isLocalizable()) { + return ScalarValue::localizableValue($attributeCode, $data, $localeCode); + } + + return ScalarValue::value($attributeCode, $data); + } + + public function createByCheckingData(Attribute $attribute, ?string $channelCode, ?string $localeCode, $data): ValueInterface + { + if (!is_array($data)) { + throw InvalidPropertyTypeException::arrayExpected( + $attribute->code(), + static::class, + $data + ); + } + + try { + Assert::allString($data); + } catch (Exception $exception) { + throw InvalidPropertyTypeException::validArrayStructureExpected( + $attribute->code(), + 'one of the options is not a string', + static::class, + $data + ); + } + + return $this->createWithoutCheckingData($attribute, $channelCode, $localeCode, $data); + } + + public function supportedAttributeType(): string + { + return ExtendedAttributeTypes::TEXT_COLLECTION; + } +// /** @var string */ +// protected $productValueClass; +// +// /** @var string */ +// protected $supportedAttributeTypes; +//x +// /** +// * @param string $productValueClass +// * @param string $supportedAttributeTypes +// */ +// public function __construct($productValueClass, $supportedAttributeTypes) +// { +// $this->productValueClass = $productValueClass; +// $this->supportedAttributeTypes = $supportedAttributeTypes; +// } +// +// /** +// * {@inheritdoc} +// */ +// public function create(AttributeInterface $attribute, $channelCode, $localeCode, $data) +// { +// $this->checkData($attribute, $data); +// +// if (null !== $data) { +// $data = $this->convertData($attribute, $data); +// } +// +// $value = new $this->productValueClass($attribute, $channelCode, $localeCode, $data); +// +// return $value; +// } +// +// /** +// * {@inheritdoc} +// */ +// public function supports($attributeType) +// { +// return $attributeType === $this->supportedAttributeTypes; +// } +// +// /** +// * @param AttributeInterface $attribute +// * @param mixed $data +// * +// * @throws InvalidPropertyTypeException +// */ +// protected function checkData(AttributeInterface $attribute, $data) +// { +// if (null === $data) { +// return; +// } +// +// if (!is_array($data)) { +// throw InvalidPropertyTypeException::arrayExpected( +// $attribute->getCode(), +// static::class, +// $data +// ); +// } +// } +// +// /** +// * @param AttributeInterface $attribute +// * @param mixed $data +// * +// * @return mixed +// */ +// protected function convertData(AttributeInterface $attribute, $data) +// { +// if (is_string($data) && '' === trim($data)) { +// $data = null; +// } +// +// if (AttributeTypes::BOOLEAN === $attribute->getType() && +// (1 === $data || '1' === $data || 0 === $data || '0' === $data) +// ) { +// $data = boolval($data); +// } +// +// return $data; +// } +} diff --git a/src/Filter/FilterProvider.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Filter/FilterProvider.php old mode 100644 new mode 100755 similarity index 76% rename from src/Filter/FilterProvider.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Filter/FilterProvider.php index 2373006..83ee3f1 --- a/src/Filter/FilterProvider.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Filter/FilterProvider.php @@ -2,9 +2,12 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Filter; -use Pim\Bundle\EnrichBundle\Provider\Filter\FilterProviderInterface; +//use Pim\Bundle\EnrichBundle\Provider\Filter\FilterProviderInterface; +//use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; +//use Pim\Component\Catalog\Model\AttributeInterface; +use Akeneo\Pim\Structure\Component\Model\AttributeInterface; +use Akeneo\Platform\Bundle\UIBundle\Provider\Filter\FilterProviderInterface; use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; -use Pim\Component\Catalog\Model\AttributeInterface; /** * Filter provider for text collection attribute diff --git a/src/Filter/ProductValue/TextCollectionFilter.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Filter/ProductValue/TextCollectionFilter.php old mode 100644 new mode 100755 similarity index 67% rename from src/Filter/ProductValue/TextCollectionFilter.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Filter/ProductValue/TextCollectionFilter.php index c9edd20..5c8f54d --- a/src/Filter/ProductValue/TextCollectionFilter.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Filter/ProductValue/TextCollectionFilter.php @@ -2,11 +2,17 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Filter\ProductValue; +//use Oro\Bundle\FilterBundle\Form\Type\Filter\FilterType; +//use Oro\Bundle\FilterBundle\Form\Type\Filter\TextFilterType; +//use Pim\Bundle\ExtendedAttributeTypeBundle\DataGrid\Form\Type\Filter\TextCollectionFilterType; +//use Pim\Bundle\FilterBundle\Filter\ProductValue\StringFilter; +//use Pim\Component\Catalog\Query\Filter\Operators; +//use Oro\Bundle\FilterBundle\Filter\StringFilter; +use Akeneo\Pim\Enrichment\Component\Product\Query\Filter\Operators; use Oro\Bundle\FilterBundle\Form\Type\Filter\FilterType; use Oro\Bundle\FilterBundle\Form\Type\Filter\TextFilterType; +use Oro\Bundle\PimFilterBundle\Filter\ProductValue\StringFilter; use Pim\Bundle\ExtendedAttributeTypeBundle\DataGrid\Form\Type\Filter\TextCollectionFilterType; -use Pim\Bundle\FilterBundle\Filter\ProductValue\StringFilter; -use Pim\Component\Catalog\Query\Filter\Operators; /** * TextCollectionFilter @@ -32,9 +38,4 @@ protected function getFormType() { return TextCollectionFilterType::class; } - - public function getForm() - { - return parent::getForm(); // TODO: Change the autogenerated stub - } } diff --git a/src/Pim/Bundle/ExtendedAttributeTypeBundle/Model/TextCollectionValue.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Model/TextCollectionValue.php new file mode 100755 index 0000000..13ff47f --- /dev/null +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Model/TextCollectionValue.php @@ -0,0 +1,70 @@ + + * @copyright 2017 Akeneo SAS (http://www.akeneo.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +class TextCollectionValue extends AbstractValue +{ + /** @var string[] */ + protected $data; + + + protected function __construct(string $attributeCode, $data, ?string $scopeCode, ?string $localeCode) + { + parent::__construct($attributeCode, $data, $scopeCode, $localeCode); + } + + /** + * @return string[] + */ + public function getData() + { + return $this->data; + } + + /** + * @param string $item + */ + public function removeItem(string $item) + { + $data = array_filter($this->data, function ($value) use ($item) { + return $value !== $item; + }); + $this->data = array_values($data); + } + + public function isEqual(ValueInterface $value): bool + { + if (!$value instanceof TextCollectionValue || + $this->getScopeCode() !== $value->getScopeCode() || + $this->getLocaleCode() !== $value->getLocaleCode()) { + return false; + } + + $comparedAttributeOptions = $value->getData(); + $thisAttributeOptions = $this->getData(); + + return count(array_diff($thisAttributeOptions, $comparedAttributeOptions)) === 0 && + count(array_diff($comparedAttributeOptions, $thisAttributeOptions)) === 0; + } + + /** + * {@inheritdoc} + */ + public function __toString(): string + { + return implode(', ', $this->data); + } +} diff --git a/src/Normalizer/Flat/TextCollectionDenormalizerFlat.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Normalizer/Flat/TextCollectionDenormalizerFlat.php old mode 100644 new mode 100755 similarity index 86% rename from src/Normalizer/Flat/TextCollectionDenormalizerFlat.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Normalizer/Flat/TextCollectionDenormalizerFlat.php index 979e1af..758b7d6 --- a/src/Normalizer/Flat/TextCollectionDenormalizerFlat.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Normalizer/Flat/TextCollectionDenormalizerFlat.php @@ -3,6 +3,7 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Normalizer\Flat; use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\TextCollectionType; +use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer; /** * Denormalize flat text collection: @@ -13,7 +14,7 @@ * @copyright 2017 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class TextCollectionDenormalizerFlat extends Denormalizer +class TextCollectionDenormalizerFlat extends ArrayDenormalizer { /** * {@inheritdoc} diff --git a/src/Pim/Bundle/ExtendedAttributeTypeBundle/Normalizer/Indexing/Value/TextCollectionNormalizer.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Normalizer/Indexing/Value/TextCollectionNormalizer.php new file mode 100755 index 0000000..e611b95 --- /dev/null +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Normalizer/Indexing/Value/TextCollectionNormalizer.php @@ -0,0 +1,68 @@ + + * @copyright 2017 Akeneo SAS (http://www.akeneo.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +class TextCollectionNormalizer extends AbstractProductValueNormalizer implements CacheableSupportsMethodInterface +{ +// /** +// * {@inheritdoc} +// */ +// public function supportsNormalization($data, $format = null) +// { +// return $data instanceof TextCollectionValue && ( +//// $format === PublishedProductNormalizer::INDEXING_FORMAT_PRODUCT_INDEX || +////// $format === ProductModel\ProductModelNormalizer::INDEXING_FORMAT_PRODUCT_MODEL_INDEX || +//// $format === ValueCollectionNormalizer::INDEXING_FORMAT_PRODUCT_AND_MODEL_INDEX +//// $format === \Akeneo\Pim\Enrichment\Component\Product\Normalizer\Indexing\ProductAndProductModel\ProductModelNormalizer::INDEXING_FORMAT_PRODUCT_AND_MODEL_INDEX +// +// +// $format === ProductNormalizer::INDEXING_FORMAT_PRODUCT_INDEX || +// $format === ProductModelNormalizer::INDEXING_FORMAT_PRODUCT_MODEL_INDEX || +// $format === \Akeneo\Pim\Enrichment\Component\Product\Normalizer\Indexing\ProductAndProductModel\ProductModelNormalizer::INDEXING_FORMAT_PRODUCT_AND_MODEL_INDEX +// ); +// } + + /** + * {@inheritdoc} + */ + public function supportsNormalization($data, $format = null) + { + return $data instanceof TextCollectionValue && ( + $format === ValueCollectionNormalizer::INDEXING_FORMAT_PRODUCT_AND_MODEL_INDEX + ); + } + + public function hasCacheableSupportsMethod(): bool + { + return true; + } + + /** + * {@inheritdoc} + */ + protected function getNormalizedData(ValueInterface $value) + { + return $value->getData(); + } +} diff --git a/src/PimExtendedAttributeTypeBundle.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/PimExtendedAttributeTypeBundle.php old mode 100644 new mode 100755 similarity index 51% rename from src/PimExtendedAttributeTypeBundle.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/PimExtendedAttributeTypeBundle.php index f382939..388cffb --- a/src/PimExtendedAttributeTypeBundle.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/PimExtendedAttributeTypeBundle.php @@ -2,7 +2,7 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle; -use Pim\Bundle\ElasticSearchBundle\Query\ProductQueryUtility; +//use Pim\Bundle\ElasticSearchBundle\Query\ProductQueryUtility; use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -13,13 +13,4 @@ */ class PimExtendedAttributeTypeBundle extends Bundle { - public function boot() - { - parent::boot(); - - $registeredBundles = $this->container->getParameter('kernel.bundles'); - if (array_key_exists('PimElasticSearchBundle', $registeredBundles)) { - ProductQueryUtility::addTypeSuffix(ExtendedAttributeTypes::TEXT_COLLECTION, ProductQueryUtility::SUFFIX_TEXT); - } - } } diff --git a/src/Provider/Field/TextCollectionProvider.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Provider/Field/TextCollectionProvider.php old mode 100644 new mode 100755 similarity index 63% rename from src/Provider/Field/TextCollectionProvider.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Provider/Field/TextCollectionProvider.php index 18acc22..7153195 --- a/src/Provider/Field/TextCollectionProvider.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Provider/Field/TextCollectionProvider.php @@ -2,9 +2,13 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Provider\Field; -use Pim\Bundle\EnrichBundle\Provider\Field\FieldProviderInterface; +//use Pim\Bundle\EnrichBundle\Provider\Field\FieldProviderInterface; +//use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; +//use Pim\Component\Catalog\Model\AttributeInterface; + +use Akeneo\Pim\Structure\Component\Model\AttributeInterface; +use Akeneo\Platform\Bundle\UIBundle\Provider\Field\FieldProviderInterface; use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; -use Pim\Component\Catalog\Model\AttributeInterface; class TextCollectionProvider implements FieldProviderInterface { diff --git a/src/Resources/config/array_converters.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/array_converters.yml old mode 100644 new mode 100755 similarity index 93% rename from src/Resources/config/array_converters.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/array_converters.yml index 9f75759..f615890 --- a/src/Resources/config/array_converters.yml +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/array_converters.yml @@ -1,6 +1,6 @@ parameters: - pim_extended_attribute_type.array_converter.flat_to_standard.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\ArrayConverter\FlatToStandard\Product\ValueConverter\TextCollectionConverter pim_extended_attribute_type.array_converter.standard_to_flat.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\ArrayConverter\StandardToFlat\Product\ValueConverter\TextCollectionConverter + pim_extended_attribute_type.array_converter.flat_to_standard.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\ArrayConverter\FlatToStandard\Product\ValueConverter\TextCollectionConverter services: pim_extended_attribute_type.array_converter.standard_to_flat.product.value_converter.text_collection: @@ -14,6 +14,7 @@ services: pim_extended_attribute_type.array_converter.flat_to_standard.product.value_converter.text_collection: class: '%pim_extended_attribute_type.array_converter.flat_to_standard.text_collection.class%' arguments: + - '@pim_connector.array_converter.flat_to_standard.product.field_splitter' - ['pim_catalog_text_collection'] tags: - { name: 'pim_connector.array_converter.flat_to_standard.product.value_converter' } diff --git a/src/Resources/config/assets.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/assets.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/assets.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/assets.yml diff --git a/src/Resources/config/attribute_icons.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/attribute_icons.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/attribute_icons.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/attribute_icons.yml diff --git a/src/Resources/config/attribute_types.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/attribute_types.yml old mode 100644 new mode 100755 similarity index 56% rename from src/Resources/config/attribute_types.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/attribute_types.yml index d53374e..03627a6 --- a/src/Resources/config/attribute_types.yml +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/attribute_types.yml @@ -1,13 +1,10 @@ parameters: pim_extended_attribute_type.attribute_type.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\TextCollectionType - pim_extended_attribute_type.validator.constraint_guesser.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\Validator\ConstraintGuesser\TextCollectionGuesser services: pim_extended_attribute_type.attribute_type.text_collection: class: '%pim_extended_attribute_type.attribute_type.text_collection.class%' arguments: - - textCollection - - text - - '@pim_catalog.validator.constraint_guesser.chained_attribute' + - 'text_collection' tags: - - { name: pim_catalog.attribute_type, alias: pim_catalog_text_collection } + - { name: pim_catalog.attribute_type, alias: pim_catalog_text_collection, entity: '%pim_catalog.entity.product.class%' } diff --git a/src/Resources/config/comparators.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/comparators.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/comparators.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/comparators.yml diff --git a/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/completeness_mask_generators.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/completeness_mask_generators.yml new file mode 100644 index 0000000..8e4596a --- /dev/null +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/completeness_mask_generators.yml @@ -0,0 +1,4 @@ +services: + pim_extended_attribute_type.pim.enrichment.completeness.mask_item_generator.extended_attribute: + class: 'Pim\Bundle\ExtendedAttributeTypeBundle\Component\Product\Completeness\MaskItemGenerator\ExtendedAttributeTypeMaskItem' + tags: [{ name: akeneo.pim.enrichment.completeness.mask_item_generator }] diff --git a/src/Resources/config/datagrid/attribute_types.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/datagrid/attribute_types.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/datagrid/attribute_types.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/datagrid/attribute_types.yml diff --git a/src/Resources/config/datagrid/filters.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/datagrid/filters.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/datagrid/filters.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/datagrid/filters.yml diff --git a/src/Resources/config/denormalizers.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/denormalizers.yml old mode 100644 new mode 100755 similarity index 85% rename from src/Resources/config/denormalizers.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/denormalizers.yml index 48a340b..fa6b5c1 --- a/src/Resources/config/denormalizers.yml +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/denormalizers.yml @@ -13,5 +13,7 @@ services: pim_extended_attribute_type.normalizer.indexing_product.product.text_collection: class: '%pim_extended_attribute_type.normalizer.indexing_product.product.text_collection.class%' + arguments: + - '@akeneo.pim.structure.query.get_attributes' tags: - - { name: pim_serializer.normalizer, priority: 90 } + - { name: pim_indexing_serializer.normalizer, priority: 90 } diff --git a/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/elasticsearch/product_mapping.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/elasticsearch/product_mapping.yml new file mode 100755 index 0000000..04b8746 --- /dev/null +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/elasticsearch/product_mapping.yml @@ -0,0 +1,17 @@ +#See PR 6980 for a detailled explaination of the configuration +#https://github.com/akeneo/pim-community-dev/pull/6980 +mappings: + # properties: + dynamic_templates: + - + text_collection_scopable_localizable_structure: + path_match: 'values.*-text_collection.*' + match_mapping_type: 'object' + mapping: + type: 'object' + - + text_collection: + path_match: 'values.*-text_collection.*' + mapping: + type: 'keyword' + normalizer: 'attribute_text_collection_normalizer' diff --git a/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/elasticsearch/settings.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/elasticsearch/settings.yml new file mode 100644 index 0000000..1bba090 --- /dev/null +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/elasticsearch/settings.yml @@ -0,0 +1,5 @@ +settings: + analysis: + normalizer: + attribute_text_collection_normalizer: + filter: ['lowercase'] diff --git a/src/Resources/config/entities.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/entities.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/entities.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/entities.yml diff --git a/src/Resources/config/form_extensions.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/form_extensions.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/form_extensions.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/form_extensions.yml diff --git a/src/Resources/config/form_extensions/filters.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/form_extensions/filters.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/form_extensions/filters.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/form_extensions/filters.yml diff --git a/src/Resources/config/form_types.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/form_types.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/form_types.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/form_types.yml diff --git a/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/product_value_factories.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/product_value_factories.yml new file mode 100755 index 0000000..65261bd --- /dev/null +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/product_value_factories.yml @@ -0,0 +1,8 @@ +parameters: + pim_catalog.factory.value.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\Factory\Value\TextCollectionValueFactory + +services: + akeneo.pim.enrichment.factory.value.text_collection: + class: '%pim_catalog.factory.value.text_collection.class%' + tags: ['akeneo.pim.enrichment.factory.product_value'] + diff --git a/src/Resources/config/providers.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/providers.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/providers.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/providers.yml diff --git a/src/Resources/config/query_builders.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/query_builders.yml old mode 100644 new mode 100755 similarity index 68% rename from src/Resources/config/query_builders.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/query_builders.yml index a4cfab0..0a18434 --- a/src/Resources/config/query_builders.yml +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/query_builders.yml @@ -1,12 +1,12 @@ parameters: - pim_catalog.query.elasticsearch.filter.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\Elasticsearch\Filter\Attribute\TextCollectionFilter + pim_catalog.query.elasticsearch.filter.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\Elasticsearch\Filter\Attribute\TextCollectionFilter services: pim_catalog.query.elasticsearch.filter.text_collection: class: '%pim_catalog.query.elasticsearch.filter.text_collection.class%' arguments: - '@pim_catalog.validator.helper.attribute' - - [!php/const:\Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] + - [!php/const Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] - ['CONTAINS', 'DOES NOT CONTAIN', 'EMPTY', 'NOT EMPTY'] tags: - { name: 'pim_catalog.elasticsearch.query.product_filter', priority: 30 } diff --git a/src/Resources/config/query_builders_ee.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/query_builders_ee.yml old mode 100644 new mode 100755 similarity index 83% rename from src/Resources/config/query_builders_ee.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/query_builders_ee.yml index 3a1b27d..ac17896 --- a/src/Resources/config/query_builders_ee.yml +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/query_builders_ee.yml @@ -6,7 +6,7 @@ services: class: '%pimee_workflow.query.elasticsearch.filter.text_collection.class%' arguments: - '@pimee_workflow.query.elasticsearch.attribute_path_resolver' - - [!php/const:\Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] + - [!php/const Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] - ['CONTAINS', 'DOES NOT CONTAIN', 'EMPTY', 'NOT EMPTY'] tags: - { name: 'pimee_workflow.elasticsearch.query.product_proposal_filter', priority: 40 } diff --git a/src/Resources/config/requirejs.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/requirejs.yml old mode 100644 new mode 100755 similarity index 86% rename from src/Resources/config/requirejs.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/requirejs.yml index 29a74b5..da16079 --- a/src/Resources/config/requirejs.yml +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/requirejs.yml @@ -2,7 +2,6 @@ config: paths: pim-extended-attribute-type/text-collection-field: pimextendedattributetype/js/product/field/text-collection-field pim-extended-attribute-type/templates/product/field/text-collection: pimextendedattributetype/templates/product/field/text-collection.html - pim-extended-attribute-type/templates/product/field/text-collection: pimextendedattributetype/templates/product/field/text-collection.html pim-extended-attribute-type/templates/datagrid/cell/text-collection: pimextendedattributetype/templates/datagrid/cell/text_collection.html oro/datagrid/text_collection-cell: pimextendedattributetype/js/datagrid/cell/text_collection-cell diff --git a/src/Resources/config/storage_driver/doctrine/elasticsearch.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/storage_driver/doctrine/elasticsearch.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/config/storage_driver/doctrine/elasticsearch.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/storage_driver/doctrine/elasticsearch.yml diff --git a/src/Resources/config/updaters.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/updaters.yml old mode 100644 new mode 100755 similarity index 61% rename from src/Resources/config/updaters.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/updaters.yml index a39840c..a652fae --- a/src/Resources/config/updaters.yml +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/updaters.yml @@ -4,7 +4,7 @@ services: class: '%pim_catalog.updater.setter.value.class%' parent: pim_catalog.updater.setter.abstract arguments: - - [!php/const:\Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] + - [!php/const Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] tags: - { name: 'pim_catalog.updater.setter' } @@ -14,7 +14,7 @@ services: parent: pim_catalog.updater.copier.abstract arguments: - '@pim_serializer' - - [!php/const:\Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] - - [!php/const:\Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] + - [!php/const Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] + - [!php/const Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION] tags: - { name: 'pim_catalog.updater.copier' } diff --git a/src/Resources/config/validators.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/validators.yml old mode 100644 new mode 100755 similarity index 60% rename from src/Resources/config/validators.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/validators.yml index d52a0ba..bffd0c8 --- a/src/Resources/config/validators.yml +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/config/validators.yml @@ -1,3 +1,6 @@ +parameters: + pim_extended_attribute_type.validator.constraint_guesser.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\Validator\ConstraintGuesser\TextCollectionGuesser + services: pim_extended_attribute_type.validator.constraint_guesser.text_collection: public: false diff --git a/src/Resources/public/css/text-collection.less b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/css/text-collection.less old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/public/css/text-collection.less rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/css/text-collection.less diff --git a/src/Resources/public/js/datafilter/filter/range-filter.js b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/js/datafilter/filter/range-filter.js old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/public/js/datafilter/filter/range-filter.js rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/js/datafilter/filter/range-filter.js diff --git a/src/Resources/public/js/datagrid/cell/text_collection-cell.js b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/js/datagrid/cell/text_collection-cell.js old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/public/js/datagrid/cell/text_collection-cell.js rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/js/datagrid/cell/text_collection-cell.js diff --git a/src/Resources/public/js/product/field/text-collection-field.js b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/js/product/field/text-collection-field.js old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/public/js/product/field/text-collection-field.js rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/js/product/field/text-collection-field.js diff --git a/src/Resources/public/templates/datagrid/cell/text_collection.html b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/templates/datagrid/cell/text_collection.html old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/public/templates/datagrid/cell/text_collection.html rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/templates/datagrid/cell/text_collection.html diff --git a/src/Resources/public/templates/product/field/text-collection.html b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/templates/product/field/text-collection.html old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/public/templates/product/field/text-collection.html rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/public/templates/product/field/text-collection.html diff --git a/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/translations/jsmessages.en.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/translations/jsmessages.en.yml new file mode 100755 index 0000000..0916b30 --- /dev/null +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/translations/jsmessages.en.yml @@ -0,0 +1,3 @@ +pim_catalog_text_collection: Text Collection + +pim_enrich.entity.attribute.property.type.pim_catalog_text_collection: Text Collection diff --git a/src/Resources/translations/messages.en.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/translations/messages.en.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/translations/messages.en.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/translations/messages.en.yml diff --git a/src/Resources/translations/messages.fr.yml b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/translations/messages.fr.yml old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/translations/messages.fr.yml rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/translations/messages.fr.yml diff --git a/src/Resources/views/datagrid/property/text_collection.html.twig b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/views/datagrid/property/text_collection.html.twig old mode 100644 new mode 100755 similarity index 100% rename from src/Resources/views/datagrid/property/text_collection.html.twig rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Resources/views/datagrid/property/text_collection.html.twig diff --git a/src/Updater/Comparator/TextCollectionComparator.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Updater/Comparator/TextCollectionComparator.php old mode 100644 new mode 100755 similarity index 89% rename from src/Updater/Comparator/TextCollectionComparator.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Updater/Comparator/TextCollectionComparator.php index 35612aa..27c7d65 --- a/src/Updater/Comparator/TextCollectionComparator.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Updater/Comparator/TextCollectionComparator.php @@ -2,7 +2,8 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Updater\Comparator; -use Pim\Component\Catalog\Comparator\ComparatorInterface; +//use Pim\Component\Catalog\Comparator\ComparatorInterface; +use Akeneo\Pim\Enrichment\Component\Product\Comparator\ComparatorInterface; /** * Comparator which calculate change set for text collection diff --git a/src/Validator/ConstraintGuesser/EmailGuesser.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/EmailGuesser.php old mode 100644 new mode 100755 similarity index 62% rename from src/Validator/ConstraintGuesser/EmailGuesser.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/EmailGuesser.php index 1c49fb5..06c1c81 --- a/src/Validator/ConstraintGuesser/EmailGuesser.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/EmailGuesser.php @@ -2,9 +2,11 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Validator\ConstraintGuesser; +use Akeneo\Pim\Enrichment\Component\Product\Validator\ConstraintGuesser\EmailGuesser as AkeneoEmailGuesser; +use Akeneo\Pim\Structure\Component\Model\AttributeInterface; use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; -use Pim\Component\Catalog\Model\AttributeInterface; -use Pim\Component\Catalog\Validator\ConstraintGuesser\EmailGuesser as PimEmailGuesser; +//use Pim\Component\Catalog\Model\AttributeInterface; +//use Pim\Component\Catalog\Validator\ConstraintGuesser\EmailGuesser as PimEmailGuesser; /** * Guesser @@ -13,7 +15,7 @@ * @copyright 2017 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class EmailGuesser extends PimEmailGuesser +class EmailGuesser extends AkeneoEmailGuesser { /** * {@inheritdoc} diff --git a/src/Validator/ConstraintGuesser/LengthGuesser.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/LengthGuesser.php old mode 100644 new mode 100755 similarity index 62% rename from src/Validator/ConstraintGuesser/LengthGuesser.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/LengthGuesser.php index b3390f0..da0f32c --- a/src/Validator/ConstraintGuesser/LengthGuesser.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/LengthGuesser.php @@ -2,9 +2,11 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Validator\ConstraintGuesser; +use Akeneo\Pim\Enrichment\Component\Product\Validator\ConstraintGuesser\LengthGuesser as AkeneoLengthGuesser; +use Akeneo\Pim\Structure\Component\Model\AttributeInterface; use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; -use Pim\Component\Catalog\Model\AttributeInterface; -use Pim\Component\Catalog\Validator\ConstraintGuesser\LengthGuesser as PimLengthGuesser; +//use Pim\Component\Catalog\Model\AttributeInterface; +//use Pim\Component\Catalog\Validator\ConstraintGuesser\LengthGuesser as PimLengthGuesser; /** * Length guesser @@ -13,7 +15,7 @@ * @copyright 2017 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class LengthGuesser extends PimLengthGuesser +class LengthGuesser extends AkeneoLengthGuesser { /** * {@inheritdoc} diff --git a/src/Validator/ConstraintGuesser/RegexGuesser.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/RegexGuesser.php old mode 100644 new mode 100755 similarity index 62% rename from src/Validator/ConstraintGuesser/RegexGuesser.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/RegexGuesser.php index f570285..4daa3e6 --- a/src/Validator/ConstraintGuesser/RegexGuesser.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/RegexGuesser.php @@ -2,9 +2,11 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Validator\ConstraintGuesser; +use Akeneo\Pim\Enrichment\Component\Product\Validator\ConstraintGuesser\RegexGuesser as AkeneoRegexGuesser; +use Akeneo\Pim\Structure\Component\Model\AttributeInterface; use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; -use Pim\Component\Catalog\Model\AttributeInterface; -use Pim\Component\Catalog\Validator\ConstraintGuesser\RegexGuesser as PimRegexGuesser; +//use Pim\Component\Catalog\Model\AttributeInterface; +//use Pim\Component\Catalog\Validator\ConstraintGuesser\RegexGuesser as PimRegexGuesser; /** * Regex guesser @@ -13,7 +15,7 @@ * @copyright 2017 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class RegexGuesser extends PimRegexGuesser +class RegexGuesser extends AkeneoRegexGuesser { /** * {@inheritdoc} diff --git a/src/Validator/ConstraintGuesser/TextCollectionGuesser.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/TextCollectionGuesser.php old mode 100644 new mode 100755 similarity index 76% rename from src/Validator/ConstraintGuesser/TextCollectionGuesser.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/TextCollectionGuesser.php index 4768543..a50b6e9 --- a/src/Validator/ConstraintGuesser/TextCollectionGuesser.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/TextCollectionGuesser.php @@ -2,11 +2,15 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Validator\ConstraintGuesser; -use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; -use Pim\Component\Catalog\Model\AttributeInterface; -use Pim\Component\Catalog\Validator\ChainedAttributeConstraintGuesser; -use Pim\Component\Catalog\Validator\ConstraintGuesserInterface; +//use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; +//use Pim\Component\Catalog\Model\AttributeInterface; +//use Pim\Component\Catalog\Validator\ChainedAttributeConstraintGuesser; +//use Pim\Component\Catalog\Validator\ConstraintGuesserInterface; use Symfony\Component\Validator\Constraints as Assert; +use Akeneo\Pim\Enrichment\Component\Product\Validator\ChainedAttributeConstraintGuesser; +use Akeneo\Pim\Enrichment\Component\Product\Validator\ConstraintGuesserInterface; +use Akeneo\Pim\Structure\Component\Model\AttributeInterface; +use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; /** * Validation guesser for the text collection attribute type. diff --git a/src/Validator/ConstraintGuesser/UrlGuesser.php b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/UrlGuesser.php old mode 100644 new mode 100755 similarity index 58% rename from src/Validator/ConstraintGuesser/UrlGuesser.php rename to src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/UrlGuesser.php index d212d1f..b4b6126 --- a/src/Validator/ConstraintGuesser/UrlGuesser.php +++ b/src/Pim/Bundle/ExtendedAttributeTypeBundle/Validator/ConstraintGuesser/UrlGuesser.php @@ -2,9 +2,12 @@ namespace Pim\Bundle\ExtendedAttributeTypeBundle\Validator\ConstraintGuesser; +//use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; +//use Pim\Component\Catalog\Model\AttributeInterface; +//use Pim\Component\Catalog\Validator\ConstraintGuesser\UrlGuesser as PimUrlGuesser; +use Akeneo\Pim\Enrichment\Component\Product\Validator\ConstraintGuesser\UrlGuesser as AkeneoUrlGuesser; +use Akeneo\Pim\Structure\Component\Model\AttributeInterface; use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes; -use Pim\Component\Catalog\Model\AttributeInterface; -use Pim\Component\Catalog\Validator\ConstraintGuesser\UrlGuesser as PimUrlGuesser; /** * Url guesser @@ -13,7 +16,7 @@ * @copyright 2017 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class UrlGuesser extends PimUrlGuesser +class UrlGuesser extends AkeneoUrlGuesser { /** * {@inheritdoc} diff --git a/src/Resources/config/completeness.yml b/src/Resources/config/completeness.yml deleted file mode 100644 index e8e9b7e..0000000 --- a/src/Resources/config/completeness.yml +++ /dev/null @@ -1,8 +0,0 @@ -parameters: - pim_extended_attribute_type.completeness.checker.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\Completeness\Checker\TextCollectionCompleteChecker - -services: - pim_extended_attribute_type.completeness.checker.text_collection: - class: '%pim_extended_attribute_type.completeness.checker.text_collection.class%' - tags: - - { name: pim_catalog.completeness.checker.product_value, priority: 100 } diff --git a/src/Resources/config/elasticsearch/index_configuration.yml b/src/Resources/config/elasticsearch/index_configuration.yml deleted file mode 100644 index 1d60db9..0000000 --- a/src/Resources/config/elasticsearch/index_configuration.yml +++ /dev/null @@ -1,17 +0,0 @@ -#See PR 6980 for a detailled explaination of the configuration -#https://github.com/akeneo/pim-community-dev/pull/6980 -mappings: - pim_catalog_product: - dynamic_templates: - - - text_collection_scopable_localizable_structure: - path_match: 'values.*-textCollection.*' - match_mapping_type: 'object' - mapping: - type: 'object' - - - text_collection: - path_match: 'values.*-textCollection.*' - mapping: - type: 'keyword' - index: 'not_analyzed' diff --git a/src/Resources/config/elasticsearch/index_configuration_ee.yml b/src/Resources/config/elasticsearch/index_configuration_ee.yml deleted file mode 100644 index 8dea1e2..0000000 --- a/src/Resources/config/elasticsearch/index_configuration_ee.yml +++ /dev/null @@ -1,32 +0,0 @@ -#See PR 6980 for a detailled explaination of the configuration -#https://github.com/akeneo/pim-community-dev/pull/6980 -mappings: - pimee_workflow_published_product: - dynamic_templates: - - - text_collection_scopable_localizable_structure: - path_match: 'values.*-textCollection.*' - match_mapping_type: 'object' - mapping: - type: 'object' - - - text_collection: - path_match: 'values.*-textCollection.*' - mapping: - type: 'keyword' - index: 'not_analyzed' - - pimee_workflow_product_proposal: - dynamic_templates: - - - text_collection_scopable_localizable_structure: - path_match: 'values.*-textCollection.*' - match_mapping_type: 'object' - mapping: - type: 'object' - - - text_collection: - path_match: 'values.*-textCollection.*' - mapping: - type: 'keyword' - index: 'not_analyzed' diff --git a/src/Resources/config/factories.yml b/src/Resources/config/factories.yml deleted file mode 100644 index b3174be..0000000 --- a/src/Resources/config/factories.yml +++ /dev/null @@ -1,13 +0,0 @@ -parameters: - pim_catalog.factory.value.text_collection.class: Pim\Bundle\ExtendedAttributeTypeBundle\Factory\Value\TextCollectionValueFactory - -services: - pim_catalog.factory.value.text_collection: - class: '%pim_catalog.factory.value.text_collection.class%' - public: false - arguments: - - '%pim_catalog.entity.value.text_collection.class%' - - !php/const:\Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes::TEXT_COLLECTION - tags: - - { name: pim_catalog.factory.value } - diff --git a/src/Resources/translations/jsmessages.en.yml b/src/Resources/translations/jsmessages.en.yml deleted file mode 100644 index 7954a41..0000000 --- a/src/Resources/translations/jsmessages.en.yml +++ /dev/null @@ -1,3 +0,0 @@ -pim_catalog_text_collection: Text Collection - -pim_enrich.entity.attribute.type.pim_catalog_text_collection: Text Collection