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

[Index] introduce new abstract function to allow handling array data better for other providers #803

Merged
merged 1 commit into from
Feb 4, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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