protected function transformNested($objects, array $fields)
    {
        if (is_array($objects) || $objects instanceof \Traversable || $objects instanceof \ArrayAccess) {
            $documents = [];
            foreach ($objects as $object) {
                $document = $this->transformObjectToDocument($object, $fields);
                $documents[] = $document->getData();
            }

            return $documents;
        } elseif (null !== $objects) {
            $document = $this->transformObjectToDocument($objects, $fields);

            return $document->getData();
        }

        return [];
    }
protected function transformNested($objects, array $fields)
    {
        if (is_array($objects) || $objects instanceof \Traversable || $objects instanceof \ArrayAccess) {
            $documents = [];
            foreach ($objects as $object) {
                $document = $this->transformObjectToDocument($object, $fields);
                $documents[] = $document->getData();
            }

            return $documents;
        } elseif (null !== $objects) {
            $document = $this->transformObjectToDocument($objects, $fields);

            return $document->getData();
        }

        return [];
    }
protected function transformNested ( $ objects , array $ fields ) { if ( is_array ( $ objects ) || $ objects instanceof \ Traversable || $ objects instanceof \ ArrayAccess ) { $ documents = [ ] ; foreach ( $ objects as $ object ) { $ document = $ this -> transformObjectToDocument ( $ object , $ fields ) ; $ documents [ ] = $ document -> getData ( ) ; } return $ documents ; } elseif ( null !== $ objects ) { $ document = $ this -> transformObjectToDocument ( $ objects , $ fields ) ; return $ document -> getData ( ) ; } return [ ] ; }
transform a nested document or an object property into an array of ElasticaDocument.

@param array|\Traversable|\ArrayAccess $objects the object to convert
@param array                           $fields  the keys we want to have in the returned array

@return array
transform a nested document or an object property into an array of ElasticaDocument .