src/php/main/Eix/Services/Data/Sources/MongoDB.php
private static function convertFromMongo(array $data)
    {
        // Move the Mongo _id field into an 'id' field.
        if (isset($data['_id'])) {
            $data['id'] = $data['_id'];
            unset($data['_id']);
        }

        foreach ($data as $name => &$value) {
            if (is_array($value)) {
                // Inner documents are converted too.
                $value = self::convertFromMongo($value);
            } elseif (is_object($value)) {
                switch (get_class($value)) {
                    case 'MongoId':
                        $value = $value->__toString();
                        break;
                    case 'MongoDate':
                        $value = new \DateTime('@' . $value->sec);
                        break;
                }
            }
        }

        return $data;
    }
private static function convertFromMongo(array $data)
    {
        // Move the Mongo _id field into an 'id' field.
        if (isset($data['_id'])) {
            $data['id'] = $data['_id'];
            unset($data['_id']);
        }

        foreach ($data as $name => &$value) {
            if (is_array($value)) {
                // Inner documents are converted too.
                $value = self::convertFromMongo($value);
            } elseif (is_object($value)) {
                switch (get_class($value)) {
                    case 'MongoId':
                        $value = $value->__toString();
                        break;
                    case 'MongoDate':
                        $value = new \DateTime('@' . $value->sec);
                        break;
                }
            }
        }

        return $data;
    }
private static function convertFromMongo ( array $ data ) { // Move the Mongo _id field into an 'id' field. if ( isset ( $ data [ '_id' ] ) ) { $ data [ 'id' ] = $ data [ '_id' ] ; unset ( $ data [ '_id' ] ) ; } foreach ( $ data as $ name => & $ value ) { if ( is_array ( $ value ) ) { // Inner documents are converted too. $ value = self :: convertFromMongo ( $ value ) ; } elseif ( is_object ( $ value ) ) { switch ( get_class ( $ value ) ) { case 'MongoId' : $ value = $ value -> __toString ( ) ; break ; case 'MongoDate' : $ value = new \ DateTime ( '@' . $ value -> sec ) ; break ; } } } return $ data ; }
Convert the various Mongo-based objects into PHP standard types, and
apply other conversions to standardise Mongo's idiosyncrasies.

@param  array $data the data that will be passed to Mongo for storage.
@return array
Convert the various Mongo - based objects into PHP standard types and apply other conversions to standardise Mongo s idiosyncrasies .