Skip to content

Commit

Permalink
Merge pull request #803 from dpfaffenbauer/index-arrays
Browse files Browse the repository at this point in the history
[Index] introduce new abstract function to allow handling array data better for other providers
  • Loading branch information
dpfaffenbauer authored Feb 4, 2019
2 parents 6cb9d85 + 6d952c3 commit 2717661
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/CoreShop/Bundle/IndexBundle/Worker/AbstractWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected function prepareData(IndexInterface $index, IndexableInterface $object

if (!$isLocalizedValue) {
if (is_array($value)) {
$value = ',' . implode($value, ',') . ',';
$value = $this->handleArrayValues($index, $value);
}

$value = $this->typeCastValues($column, $value);
Expand Down Expand Up @@ -229,6 +229,13 @@ protected function prepareData(IndexInterface $index, IndexableInterface $object
*/
abstract protected function typeCastValues(IndexColumnInterface $column, $value);

/**
* @param IndexInterface $index
* @param array $value
* @return mixed
*/
abstract protected function handleArrayValues(IndexInterface $index, array $value);

/**
* @param IndexColumnInterface $column
* @param IndexableInterface $object
Expand Down
8 changes: 8 additions & 0 deletions src/CoreShop/Bundle/IndexBundle/Worker/MysqlWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ protected function typeCastValues(IndexColumnInterface $column, $value)
return $type->convertToDatabaseValue($value, $this->database->getDatabasePlatform());
}

/**
* {@inheritdoc}
*/
protected function handleArrayValues(IndexInterface $index, array $value)
{
return ',' . implode($value, ',') . ',';
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 2717661

Please sign in to comment.