Skip to content

Commit

Permalink
#73: fix tests for pimcore 5.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Jan 14, 2019
1 parent 7578c2c commit 4ae8061
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
}
},
"require": {
"pimcore/core-version": "^5.0.0"
"pimcore/core-version": "^5.4.0"
}
}
3 changes: 3 additions & 0 deletions src/MembersBundle/CoreExtension/GroupMultiselect.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
use Pimcore\Model\Element;
use Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\ClassDefinition\Data\Relations\AbstractRelations;
use MembersBundle\Pimcore\DataObject\ClassDefinition\Data\Traits\ResourceDataTrait;
use MembersBundle\Pimcore\DataObject\ClassDefinition\Data\QueryResourcePersistenceAwareInterface;

class GroupMultiselect extends AbstractRelations implements QueryResourcePersistenceAwareInterface
{
use ResourceDataTrait;

/**
* Static type of this element.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace MembersBundle\Pimcore\DataObject\ClassDefinition\Data\Traits;

if (interface_exists(\Pimcore\Model\DataObject\ClassDefinition\Data\ResourcePersistenceAwareInterface::class)) {
trait ResourceDataTrait
{
}
} else {
trait ResourceDataTrait
{
/**
* @param $data
* @param null $object
* @param array $params
*
* @return array|null
*/
public function getDataForResource($data, $object = null, $params = [])
{
$return = [];

if (is_array($data) && count($data) > 0) {
$counter = 1;
foreach ($data as $group) {
$return[] = [
'src_id' => $object->getId(),
'dest_id' => $group->getId(),
'type' => 'object',
'fieldname' => $this->getName(),
'index' => $counter
];

$counter++;
}

return $return;
} elseif (is_array($data) and count($data) === 0) {
//give empty array if data was not null
return [];
} else {
//return null if data was null - this indicates data was not loaded
return null;
}
}
}
}

0 comments on commit 4ae8061

Please sign in to comment.