public function convertToDocument($rawData, Manager $manager)
    {
        $types = $this->metadataCollector->getMappings($manager->getConfig()['mappings']);

        if (isset($types[$rawData['_type']])) {
            $metadata = $types[$rawData['_type']];
        } else {
            throw new \LogicException("Got document of unknown type '{$rawData['_type']}'.");
        }

        switch (true) {
            case isset($rawData['_source']):
                $rawData = array_merge($rawData, $rawData['_source']);
                break;
            case isset($rawData['fields']):
                $rawData = array_merge($rawData, $rawData['fields']);
                break;
            default:
                // Do nothing.
                break;
        }

        $object = $this->assignArrayToObject($rawData, new $metadata['namespace'](), $metadata['aliases']);

        return $object;
    }
public function convertToDocument($rawData, Manager $manager)
    {
        $types = $this->metadataCollector->getMappings($manager->getConfig()['mappings']);

        if (isset($types[$rawData['_type']])) {
            $metadata = $types[$rawData['_type']];
        } else {
            throw new \LogicException("Got document of unknown type '{$rawData['_type']}'.");
        }

        switch (true) {
            case isset($rawData['_source']):
                $rawData = array_merge($rawData, $rawData['_source']);
                break;
            case isset($rawData['fields']):
                $rawData = array_merge($rawData, $rawData['fields']);
                break;
            default:
                // Do nothing.
                break;
        }

        $object = $this->assignArrayToObject($rawData, new $metadata['namespace'](), $metadata['aliases']);

        return $object;
    }
public function convertToDocument ( $ rawData , Manager $ manager ) { $ types = $ this -> metadataCollector -> getMappings ( $ manager -> getConfig ( ) [ 'mappings' ] ) ; if ( isset ( $ types [ $ rawData [ '_type' ] ] ) ) { $ metadata = $ types [ $ rawData [ '_type' ] ] ; } else { throw new \ LogicException ( "Got document of unknown type '{$rawData['_type']}'." ) ; } switch ( true ) { case isset ( $ rawData [ '_source' ] ) : $ rawData = array_merge ( $ rawData , $ rawData [ '_source' ] ) ; break ; case isset ( $ rawData [ 'fields' ] ) : $ rawData = array_merge ( $ rawData , $ rawData [ 'fields' ] ) ; break ; default : // Do nothing. break ; } $ object = $ this -> assignArrayToObject ( $ rawData , new $ metadata [ 'namespace' ] ( ) , $ metadata [ 'aliases' ] ) ; return $ object ; }
Converts raw array to document.

@param array $rawData
@param Manager $manager

@return object

@throws \LogicException
Converts raw array to document .