PHP Class Xpressengine\Document\DocumentHandler

## app binding * xe.document 로 바인딩 되어 있음 * Document facade 제공 ## 사용법 ### Instance 생성 php $documentHandler = app('xe.document'); $configEntity = $documentHandler->createInstance('newInstanceId'); $instanceManager->add($configEntity); ### 문서 등록 php $id = (new Keygen())->generate(); $inputs = ['id'=>$id', 'instanceId'=>'instance-id', 'title'=>'title', 'content'=>'content' ...]; $doc = new DocumentEntity($inputs); $documentHandler->add($doc); ### 문서 수정 php $doc = $documentHandler->get('document-id', 'instance-id'); $doc->title = 'changed title'; app('xe.document')->update($doc); ### 문서 삭제 php $doc = $documentHandler->get('document-id', 'instance-id'); app('xe.document')->remove($doc); ### 문서 조회 php instance id, document id 로 문서 갖고오기 $doc = $documentHandler->get('document-id', 'instance-id'); document id 로 문서 조회 $doc = $documentHandler->getById('document-id'); ### 문서 수 조회 php 전체 문서 수 조회회 $count = $documentHandler->count(); 인스턴스의 전체 문서 수 조회 $count = $documentHandler->countByInstanceId('instance-id'); ### 문서 목록 조회 php $wheres, $orders 는 Repository\DocumentRepository 참고 $wheres = []; $orders = []; $docs = $documentHandler->gets($wheres, $orders, 20); $paginate = $documentHandler->paginate($wheres, $orders, 20); ## 기타 ### Interception * Comment count 를 위해 DocumentServiceProvider 에서 Interception 등록
Author: XE Team (developers) ([email protected])
Show file Open project: xpressengine/xpressengine Class Usage Examples

Protected Properties

Property Type Description
$configHandler ConfigHandler
$conn Xpressengine\Database\VirtualConnectionInterface
$instanceManager InstanceManager
$model model class
$request Illuminate\Http\Request
$revisionModel model class

Public Methods

Method Description
__construct ( Xpressengine\Database\VirtualConnectionInterface $conn, ConfigHandler $configHandler, InstanceManager $instanceManager, Illuminate\Http\Request $request )
add ( array $attributes ) : Document add document
addRevision ( Document $doc ) : boolean add revision
createInstance ( string $instanceId, array $params = [] ) : ConfigEntity create document instance
destroyInstance ( string $instanceId, integer $chunk = 100 ) : void destroy document instance
get ( string $id, string $instanceId = null ) : Document get document
getConfig ( string $instanceId ) : ConfigEntity get document config
getConfigHandler ( ) : ConfigHandler get config handler
getDivisionTableName ( ConfigEntity $config ) : string get division table name
getInstanceManager ( ) : InstanceManager get repository
getModel ( string $instanceId = null ) : Document Proxy, Division 관련 설정이 된 Document model 반환 Document 는 config 를 설정해야 정상 사용 가능함 document model 를 직접 반환하지 않음
proxyOption ( ConfigEntity $config = null ) : array get database proxy options
put ( Document $doc ) : Document update document
remove ( Document $doc ) : boolean delete document
setModelConfig ( Document $doc, string $instanceId ) : Document set model's config

Protected Methods

Method Description
getRevisionModel ( ) : Revision get revision model
newModel ( ) : Document create document model config 없이 모델을 직접 생성할 경우 문제가 발생하므로 접근을 제한함
newRevisionModel ( array $attributes = [] ) : Revision create revision model
removeDivision ( Document $doc ) : void 인스턴스 아이디가 변경된 경우 이전 인스턴스의 디비전 테이블 데이터 삭제

Method Details

__construct() public method

public __construct ( Xpressengine\Database\VirtualConnectionInterface $conn, ConfigHandler $configHandler, InstanceManager $instanceManager, Illuminate\Http\Request $request )
$conn Xpressengine\Database\VirtualConnectionInterface database connection
$configHandler ConfigHandler config handler
$instanceManager InstanceManager instance manager
$request Illuminate\Http\Request Request

add() public method

add document
public add ( array $attributes ) : Document
$attributes array document attributes
return Xpressengine\Document\Models\Document

addRevision() public method

add revision
public addRevision ( Document $doc ) : boolean
$doc Xpressengine\Document\Models\Document document model
return boolean

createInstance() public method

create document instance
public createInstance ( string $instanceId, array $params = [] ) : ConfigEntity
$instanceId string instance id
$params array parameters
return Xpressengine\Config\ConfigEntity

destroyInstance() public method

destroy document instance
public destroyInstance ( string $instanceId, integer $chunk = 100 ) : void
$instanceId string instance id
$chunk integer chunk count
return void

get() public method

get document
public get ( string $id, string $instanceId = null ) : Document
$id string document id
$instanceId string instance id
return Xpressengine\Document\Models\Document

getConfig() public method

get document config
public getConfig ( string $instanceId ) : ConfigEntity
$instanceId string instance id
return Xpressengine\Config\ConfigEntity

getConfigHandler() public method

get config handler
public getConfigHandler ( ) : ConfigHandler
return ConfigHandler

getDivisionTableName() public method

get division table name
public getDivisionTableName ( ConfigEntity $config ) : string
$config Xpressengine\Config\ConfigEntity config entity
return string

getInstanceManager() public method

get repository
public getInstanceManager ( ) : InstanceManager
return InstanceManager

getModel() public method

Proxy, Division 관련 설정이 된 Document model 반환 Document 는 config 를 설정해야 정상 사용 가능함 document model 를 직접 반환하지 않음
public getModel ( string $instanceId = null ) : Document
$instanceId string document instance id
return Xpressengine\Document\Models\Document

getRevisionModel() protected method

get revision model
protected getRevisionModel ( ) : Revision
return Xpressengine\Document\Models\Revision

newModel() protected method

create document model config 없이 모델을 직접 생성할 경우 문제가 발생하므로 접근을 제한함
protected newModel ( ) : Document
return Xpressengine\Document\Models\Document

newRevisionModel() protected method

create revision model
protected newRevisionModel ( array $attributes = [] ) : Revision
$attributes array attributes
return Xpressengine\Document\Models\Revision

proxyOption() public method

get database proxy options
public proxyOption ( ConfigEntity $config = null ) : array
$config Xpressengine\Config\ConfigEntity config entity
return array

put() public method

update document
public put ( Document $doc ) : Document
$doc Xpressengine\Document\Models\Document document model
return Xpressengine\Document\Models\Document

remove() public method

delete document
public remove ( Document $doc ) : boolean
$doc Xpressengine\Document\Models\Document document model
return boolean

removeDivision() protected method

인스턴스 아이디가 변경된 경우 이전 인스턴스의 디비전 테이블 데이터 삭제
protected removeDivision ( Document $doc ) : void
$doc Xpressengine\Document\Models\Document document model
return void

setModelConfig() public method

set model's config
public setModelConfig ( Document $doc, string $instanceId ) : Document
$doc Xpressengine\Document\Models\Document document model
$instanceId string document instance id
return Xpressengine\Document\Models\Document

Property Details

$configHandler protected property

protected ConfigHandler,Xpressengine\Document $configHandler
return ConfigHandler

$conn protected property

protected VirtualConnectionInterface,Xpressengine\Database $conn
return Xpressengine\Database\VirtualConnectionInterface

$instanceManager protected property

protected InstanceManager,Xpressengine\Document $instanceManager
return InstanceManager

$model protected property

model class
protected $model

$request protected property

protected Request,Illuminate\Http $request
return Illuminate\Http\Request

$revisionModel protected property

model class
protected $revisionModel