public function get($idOrDocument, $type = Document::DOCUMENT_TYPE_CLASSIFIED) 
    {
        $neobazaarService = $this->getServiceLocator()->get('neobazaar.service.main');
        $classifiedService = $this->getServiceLocator()->get('document.service.classified');
        $documentRepository = $neobazaarService->getDocumentEntityRepository();
		$document = $documentRepository->getEntity($idOrDocument);
		$key = $documentRepository->getEncryptedId($document->getDocumentId());
		$model = null;
        
        switch($type) {
            case Document::DOCUMENT_TYPE_CLASSIFIED:
                // if the user is not Owner or Admin the public model is used
                if(!$classifiedService->checkIfOwnerOrAdmin($document)) {
                    $cache = $this->getServiceLocator()->get('ClassifiedCache');
                    if(!$model = $cache->getItem($key)) {
                        $model = $this->getServiceLocator()->get('document.model.classifiedPublicListing');
                        $model->init($document);
                    }
                } else {
                    $cache = $this->getServiceLocator()->get('ClassifiedCacheOwnerAdmin');
                    if(!$model = $cache->getItem($key)) {
                        $model = $this->getServiceLocator()->get('document.model.classifiedAdminListing');
                        $model->init($document);
                    }
                }
                break;
            case Document::DOCUMENT_TYPE_IMAGE:
            case Document::DOCUMENT_TYPE_PAGE:
            default:
                break;
        }
        
        return $model;
    }
public function get($idOrDocument, $type = Document::DOCUMENT_TYPE_CLASSIFIED) 
    {
        $neobazaarService = $this->getServiceLocator()->get('neobazaar.service.main');
        $classifiedService = $this->getServiceLocator()->get('document.service.classified');
        $documentRepository = $neobazaarService->getDocumentEntityRepository();
		$document = $documentRepository->getEntity($idOrDocument);
		$key = $documentRepository->getEncryptedId($document->getDocumentId());
		$model = null;
        
        switch($type) {
            case Document::DOCUMENT_TYPE_CLASSIFIED:
                // if the user is not Owner or Admin the public model is used
                if(!$classifiedService->checkIfOwnerOrAdmin($document)) {
                    $cache = $this->getServiceLocator()->get('ClassifiedCache');
                    if(!$model = $cache->getItem($key)) {
                        $model = $this->getServiceLocator()->get('document.model.classifiedPublicListing');
                        $model->init($document);
                    }
                } else {
                    $cache = $this->getServiceLocator()->get('ClassifiedCacheOwnerAdmin');
                    if(!$model = $cache->getItem($key)) {
                        $model = $this->getServiceLocator()->get('document.model.classifiedAdminListing');
                        $model->init($document);
                    }
                }
                break;
            case Document::DOCUMENT_TYPE_IMAGE:
            case Document::DOCUMENT_TYPE_PAGE:
            default:
                break;
        }
        
        return $model;
    }
public function get ( $ idOrDocument , $ type = Document :: DOCUMENT_TYPE_CLASSIFIED ) { $ neobazaarService = $ this -> getServiceLocator ( ) -> get ( 'neobazaar.service.main' ) ; $ classifiedService = $ this -> getServiceLocator ( ) -> get ( 'document.service.classified' ) ; $ documentRepository = $ neobazaarService -> getDocumentEntityRepository ( ) ; $ document = $ documentRepository -> getEntity ( $ idOrDocument ) ; $ key = $ documentRepository -> getEncryptedId ( $ document -> getDocumentId ( ) ) ; $ model = null ; switch ( $ type ) { case Document :: DOCUMENT_TYPE_CLASSIFIED : // if the user is not Owner or Admin the public model is used if ( ! $ classifiedService -> checkIfOwnerOrAdmin ( $ document ) ) { $ cache = $ this -> getServiceLocator ( ) -> get ( 'ClassifiedCache' ) ; if ( ! $ model = $ cache -> getItem ( $ key ) ) { $ model = $ this -> getServiceLocator ( ) -> get ( 'document.model.classifiedPublicListing' ) ; $ model -> init ( $ document ) ; } } else { $ cache = $ this -> getServiceLocator ( ) -> get ( 'ClassifiedCacheOwnerAdmin' ) ; if ( ! $ model = $ cache -> getItem ( $ key ) ) { $ model = $ this -> getServiceLocator ( ) -> get ( 'document.model.classifiedAdminListing' ) ; $ model -> init ( $ document ) ; } } break ; case Document :: DOCUMENT_TYPE_IMAGE : case Document :: DOCUMENT_TYPE_PAGE : default : break ; } return $ model ; }
Fetch the correct model depending on user auth

@param string|int|object $entity
@param unknown $type
@return object
Fetch the correct model depending on user auth