class DocumentHandler

DocumentHandler

  • 문서 등록, 수정, 삭제 할 때 intercept 할 수 있음 Document Model 자체적으로 CRUD 할 때 intercept 를 제공할 수 없는 문제 해결
  • ~Division 처리 및 DynamicQuery 관련 작업을 위해 Document Model 에 config 를 설정해야하고 이 설정을 위해 getModel() setModelConfig() 메소드가 있음~
  • Division 된 테이블을 사용하기 위해서 Document::division() 메소드에 인스턴스 아이디 주입
  • Division(테이블 분할)은 Document Model 에서 처리됨.
  • Document Model 을 이용해 Database CRUD 처리를 직접하는 경우 revision 에 대한 처리를 할 수 없으며 intercept 할 수 없음

app binding

  • xe.document 로 바인딩 되어 있음
  • Document facade 제공

사용법

Instance 생성

XeDocument::createInstance('newInstanceId');

문서 등록

$inputs = ['id'=>$id', 'instanceId'=>'instance-id', 'title'=>'title', 'content'=>'content' ...];
XeDocument::add($inputs);

문서 수정

$doc = Document::find('document-id');

$doc->title = 'changed title';

XeDocument::update($doc);

문서 삭제

$doc = Document::find('document-id');

XeDocument::remove($doc);

문서 조회

$doc = Document::find('document-id');

$doc = XeDocument::get('document-id', 'instance-id');

// 모델에 division 을 설정하면 분리된 테이블 사용
$model = Document::division('instanceId');
$doc = $model->get('document-id');

문서 수 조회

// 전체 문서 수 조회회
$count = Document::count();

// division 된 테이블에서 인스턴스의 전체 문서 수 조회
$model = Document::division('instance-id');
$count = $model->count('instance-id');

문서 목록 조회

$perPage = 10;

$paginate = Document::paginate($perPage);

// division 된 테이블에서 조회
$model = Document::division('instance-id');
$paginate = $model->paginate($perPage);

Properties

protected document $model
protected revision $revisionModel
protected VirtualConnectionInterface $conn
protected ConfigHandler $configHandler
protected InstanceManager $instanceManager
protected Request $request

Methods

__construct(VirtualConnectionInterface $conn, ConfigHandler $configHandler, InstanceManager $instanceManager, Request $request)

No description

getConfigHandler()

get config handler

createInstance(string $instanceId, array $params = array())

create document instance

void
destroyInstance(string $instanceId, int $chunk = 100)

destroy document instance

array
proxyOption(ConfigEntity $config = null)

get database proxy options

add(array $attributes)

add document

put(Document $doc)

update document

bool
addRevision(Document $doc)

add revision

string
pivotDivisionTable(Document $doc, ConfigEntity $config)

pivot Division Table

bool
addDivision(Document $doc)

add division

bool
putDivision(Document $doc)

put division

bool
removeDivision(Document $doc)

remove division

bool
remove(Document $doc)

delete document

getConfig(string $instanceId)

get document config

newModel()

create document model

getRevisionModel()

get revision model

newRevisionModel(array $attributes = array())

create revision model

get(string $id, string $instanceId = null)

get document

Details

at line 148
__construct(VirtualConnectionInterface $conn, ConfigHandler $configHandler, InstanceManager $instanceManager, Request $request)

Parameters

VirtualConnectionInterface $conn database connection
ConfigHandler $configHandler config handler
InstanceManager $instanceManager instance manager
Request $request Request

at line 165
ConfigHandler getConfigHandler()

get config handler

Return Value

ConfigHandler

at line 175
InstanceManager getInstanceManager()

get repository

Return Value

InstanceManager

at line 187
ConfigEntity createInstance(string $instanceId, array $params = array())

create document instance

Parameters

string $instanceId instance id
array $params parameters

Return Value

ConfigEntity

at line 202
void destroyInstance(string $instanceId, int $chunk = 100)

destroy document instance

Parameters

string $instanceId instance id
int $chunk chunk count

Return Value

void

at line 224
array proxyOption(ConfigEntity $config = null)

get database proxy options

Parameters

ConfigEntity $config config entity

Return Value

array

at line 240
Document add(array $attributes)

add document

Parameters

array $attributes document attributes

Return Value

Document

at line 270
Document put(Document $doc)

update document

Parameters

Document $doc document model

Return Value

Document

at line 295
bool addRevision(Document $doc)

add revision

Parameters

Document $doc document model

Return Value

bool

at line 337
protected string pivotDivisionTable(Document $doc, ConfigEntity $config)

pivot Division Table

Parameters

Document $doc document entity
ConfigEntity $config config entity

Return Value

string

at line 350
bool addDivision(Document $doc)

add division

Parameters

Document $doc document model

Return Value

bool

at line 384
bool putDivision(Document $doc)

put division

Parameters

Document $doc document model

Return Value

bool

at line 434
bool removeDivision(Document $doc)

remove division

Parameters

Document $doc document model

Return Value

bool

at line 461
bool remove(Document $doc)

delete document

Parameters

Document $doc document model

Return Value

bool

at line 478
ConfigEntity getConfig(string $instanceId)

get document config

Parameters

string $instanceId instance id

Return Value

ConfigEntity

at line 488
protected Document newModel()

create document model

Return Value

Document

at line 498
protected Revision getRevisionModel()

get revision model

Return Value

Revision

at line 509
protected Revision newRevisionModel(array $attributes = array())

create revision model

Parameters

array $attributes attributes

Return Value

Revision

at line 521
Document get(string $id, string $instanceId = null)

get document

Parameters

string $id document id
string $instanceId instance id

Return Value

Document