* Document instance 관리 * Instance 생성 시 등록 한 설정에 따라 테이블 분리(division), 변경 이력 관리(revision) 지원 * 게시판, 페이지 같은 플러그인에서 문서를 사용하려 할 때 각각의 Config 를 사용하기 위해 instance 를 만들고 사용해야 함 ## 사용법 ### Instance 생성 php XeDocument::createInstance('newInstanceId'); ### Instance 삭제 php XeDocument::destroyInstance('newInstanceId');
Author: XE Developers (developers@xpressengine.com)
Exemplo n.º 1
0
 /**
  * get division table name
  *
  * @param ConfigEntity $config config entity
  * @return string
  */
 public function getDivisionTableName(ConfigEntity $config)
 {
     return $this->instanceManager->getDivisionTableName($config);
 }
 /**
  * test remove instance
  *
  * @return void
  */
 public function testRemove()
 {
     $repo = $this->repo;
     $configHandler = $this->configHandler;
     $manager = new InstanceManager($repo, $configHandler);
     $config = $this->getConfigEntity();
     $config->shouldReceive('get')->with('division')->andReturn(true);
     $config->shouldReceive('set');
     $config->shouldReceive('get')->with('instanceId')->andReturn('instanceId');
     $repo->shouldReceive('dropDivisionTable');
     $repo->shouldReceive('fetch')->once()->andReturn([['id' => 'id1'], ['id' => 'id2']]);
     $repo->shouldReceive('fetch')->once()->andReturn([]);
     $repo->shouldReceive('delete');
     $configHandler->shouldReceive('remove');
     $manager->remove($config);
 }
 /**
  * test remove instance
  *
  * @return void
  */
 public function testGetDivisionTableName()
 {
     $instanceId = 'instance-id';
     $configHandler = $this->configHandler;
     $config = $this->getConfigEntity();
     $config->shouldReceive('get')->with('division')->andReturn(false);
     $config->shouldReceive('get')->with('instanceId')->andReturn(null);
     $manager = new InstanceManager($this->conn, $configHandler);
     $this->assertEquals(Document::TABLE_NAME, $manager->getDivisionTableName($config));
     $config = $this->getConfigEntity();
     $config->shouldReceive('get')->with('division')->andReturn(true);
     $config->shouldReceive('get')->with('instanceId')->andReturn(null);
     $manager = new InstanceManager($this->conn, $configHandler);
     $this->assertEquals(Document::TABLE_NAME, $manager->getDivisionTableName($config));
     $config = $this->getConfigEntity();
     $config->shouldReceive('get')->with('division')->andReturn(true);
     $config->shouldReceive('get')->with('instanceId')->andReturn($instanceId);
     $manager = new InstanceManager($this->conn, $configHandler);
     $this->assertEquals(sprintf('%s_%s', Document::TABLE_NAME, $instanceId), $manager->getDivisionTableName($config));
 }
 /**
  * destroy document instance
  *
  * @param string $instanceId instance id
  * @return void
  */
 public function destroyInstance($instanceId)
 {
     $documentConfig = $this->configHandler->get($instanceId);
     $this->instanceManager->remove($documentConfig);
 }