Skip to content

Commit

Permalink
Merge pull request #250 from cakephp/3.x-composer
Browse files Browse the repository at this point in the history
Add Composer constraint for CakePHP
  • Loading branch information
markstory authored Feb 15, 2021
2 parents 2497b24 + 0b20c28 commit 525fc69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"source": "https://github.com/cakephp/elastic-search"
},
"require": {
"cakephp/cakephp": "^4.0",
"ruflin/elastica": "^6.0"
},
"require-dev": {
"cakephp/cakephp": "^4.0",
"cakephp/cakephp-codesniffer": "^4.0",
"phpunit/phpunit": "^8.5"
},
Expand Down
8 changes: 5 additions & 3 deletions src/Marshaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,16 @@ public function merge(EntityInterface $entity, array $data, array $options = [])
public function mergeMany(array $entities, array $data, array $options = [])
{
$indexed = (new Collection($data))
->groupBy('id')
->groupBy(function ($element) {
return $element['id'] ?? '';
})
->map(function ($element, $key) {
return $key === '' ? $element : $element[0];
})
->toArray();

$new = $indexed[null] ?? [];
unset($indexed[null]);
$new = $indexed[''] ?? [];
unset($indexed['']);

$output = [];
foreach ($entities as $record) {
Expand Down

0 comments on commit 525fc69

Please sign in to comment.