1 public function getDataForResource($data, $object = null, $params = [])
2 {
3 $return = [];
4
5 if (is_array($data) && count($data) > 0) {
6 $counter = 1;
7 foreach ($data as $object) {
8 if ($object instanceof Element\ElementInterface) {
9 $return[] = [
10 "dest_id" => $object->getId(),
11 "type" => Element\Service::getElementType($object),
12 "fieldname" => $this->getName(),
13 "index" => $counter
14 ];
15 }
16 $counter++;
17 }
18
19 return $return;
20 } elseif (is_array($data) and count($data) === 0) {
21 //give empty array if data was not null
22 return [];
23 } else {
24 //return null if data was null - this indicates data was not loaded
25 return null;
26 }
27 }