repository()->geContent( $documentId, $where ) ){ throw new DocumentNoContentException( 'No content yet.', 0, $where ); } $data = JSON::decode( $documentEditorJson, false ); unset( $data->computedValues ); return $data; } /** * Retrieves json of document editor data * * @param $documentId * @param array $where * * @return bool|mixed */ public function getEditorRawData( $documentId, $where = [] ){ try{ if( ! $documentEditorJson = $this->repository()->geContent( $documentId, $where ) ){ return ''; } } catch( \Exception $e ){ return ''; } return $documentEditorJson; } /** * Converts document slug or alias to document ID * * @param string|array $documentIDs A document ID/Slug/Alias or list of them * * @return mixed */ public function getID( $documentIDs ){ if( empty( $documentIDs ) ){ return false; } try{ if( is_array( $documentIDs ) ){ $realDocumentIDs = []; foreach( $documentIDs as $documentID ){ $realDocumentIDs = $this->getID( $documentID ); } return $realDocumentIDs; } elseif ( ! is_numeric( $documentIDs ) && is_string( $documentIDs ) ) { if ( $document = \Depicter::document()->repository()->findOne( null, ['slug' => $documentIDs] ) ) { return $document->getID(); } } else { return $documentIDs; } } catch( \Exception $e ){ return false; } return false; } /** * Get a document model by ID * * @param $documentId * @param array $where * * @return bool|Document * @throws EntityException * @throws \JsonMapper_Exception */ public function getModel( $documentId, $where = [] ){ $startSection = 0; if( array_key_exists( 'start', $where ) ){ $startSection = (int) $where['start']; unset( $where['start'] ); } if ( ! $editorDataArray = $this->getEditorData( $documentId, $where ) ) { return false; } $editorDataArray->startSection = $startSection; $mapper = new Mapper(); return $mapper->hydrate( $editorDataArray, $documentId )->get(); } /** * Retrieves custom css file of a document if exists * * @param int $documentId * @param array $where * * @return bool|string */ public function getCssFileUrl( $documentId, $where = [] ){ try{ if( $document = $this->getModel( $documentId, $where = [] ) ){ if( $cssFile = $document->styleGenerator()->getCssFileUrl() ){ return $cssFile; } } } catch( \Exception $e ){} return false; } /** * Get status of document * * @param int $documentID * @return string */ public function getStatus( $documentID ) { if( $document = \Depicter::document()->repository()->findById( $documentID ) ){ $document = $document->toArray(); return $document['status']; } return ''; } }