protected function getDocumentData($document)
    {
        if (is_array($document)) {
            $data = $document;
        } elseif ($document instanceof AbstractDocument) {
            $reflectionClass = new \ReflectionClass($document);
            $documentProperty = $reflectionClass->getParentClass()->getProperty('document');
            $documentProperty->setAccessible(true);
            $data = $documentProperty->getValue($document);
            foreach ($data as $key => &$value) {
                if ($value instanceof DocumentSerializableInterface) {
                    $value = $value->documentSerialize()->jsonSerialize();
                }
            }
        } else {
            throw new \Exception('Invalid data type, array or AbstractDocument expected');
        }

        return $data;
    }
protected function getDocumentData($document)
    {
        if (is_array($document)) {
            $data = $document;
        } elseif ($document instanceof AbstractDocument) {
            $reflectionClass = new \ReflectionClass($document);
            $documentProperty = $reflectionClass->getParentClass()->getProperty('document');
            $documentProperty->setAccessible(true);
            $data = $documentProperty->getValue($document);
            foreach ($data as $key => &$value) {
                if ($value instanceof DocumentSerializableInterface) {
                    $value = $value->documentSerialize()->jsonSerialize();
                }
            }
        } else {
            throw new \Exception('Invalid data type, array or AbstractDocument expected');
        }

        return $data;
    }
protected function getDocumentData ( $ document ) { if ( is_array ( $ document ) ) { $ data = $ document ; } elseif ( $ document instanceof AbstractDocument ) { $ reflectionClass = new \ ReflectionClass ( $ document ) ; $ documentProperty = $ reflectionClass -> getParentClass ( ) -> getProperty ( 'document' ) ; $ documentProperty -> setAccessible ( true ) ; $ data = $ documentProperty -> getValue ( $ document ) ; foreach ( $ data as $ key => & $ value ) { if ( $ value instanceof DocumentSerializableInterface ) { $ value = $ value -> documentSerialize ( ) -> jsonSerialize ( ) ; } } } else { throw new \ Exception ( 'Invalid data type, array or AbstractDocument expected' ) ; } return $ data ; }
Gets document data

@param $document

@return mixed

@throws \Exception
Gets document data