示例#1
0
 /**
  * 게시판 제거
  *
  * @param string $boardId board id
  * @return void
  */
 public function destroy($boardId)
 {
     $config = $this->configHandler->get($boardId);
     if ($config === null) {
         throw new Exceptions\InvalidConfigException();
     }
     $this->conn->beginTransaction();
     // get document config
     $this->document->destroyInstance($boardId);
     $this->comment->drop($boardId);
     // remove board config
     $this->configHandler->remove($config);
     // 연결된 df 제거
     foreach ($this->configHandler->getDynamicFields($config) as $config) {
         $this->dynamicField->drop($config);
     }
     $this->conn->commit();
 }
 public function testMoveByTarget()
 {
     list($member, $auth, $repo, $cfg) = $this->getMocks();
     $instance = new CommentHandler($member, $auth, $repo, $cfg);
     $mockComment1 = m::mock('Xpressengine\\Comment\\CommentEntity');
     $mockComment2 = m::mock('Xpressengine\\Comment\\CommentEntity');
     $repo->shouldReceive('fetch')->once()->with(['targetId' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'])->andReturn([$mockComment1, $mockComment2]);
     $repo->shouldReceive('moveTo')->once()->with($mockComment1, 'instanceId');
     $repo->shouldReceive('moveTo')->once()->with($mockComment2, 'instanceId');
     $instance->moveByTarget('instanceId', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
 }
示例#3
0
 /**
  * 게시판 이동
  * Document Package 에서 comment 를 지원하지 않아서 사용할 수 있는 인터페이스가 없음
  *
  * @param string         $id             document id
  * @param ConfigEntity   $config         destination board config entity
  * @param CommentHandler $commentHandler comment handler
  */
 public function move($id, ConfigEntity $config, CommentHandler $commentHandler)
 {
     if ($config === null) {
         throw new InvalidConfigException();
     }
     $item = $this->get($id);
     $doc = $item->getDocument();
     $dstInstanceId = $config->get('boardId');
     // 덧글이 있다면 덧글들을 모두 옯긴다.
     // 이거 document 인터페이스 있으멶 좋을까?? 사용 할 일 없어 보이는데.
     $rows = $this->document->getRepository()->getReplies($doc);
     foreach ($rows as $row) {
         $item = $this->get($row['id'], $row['instanceId']);
         $item->instanceId = $dstInstanceId;
         $item->getSlug()->instanceId = $dstInstanceId;
         if ($item->userId == '') {
             $item->userId = '';
         }
         $this->put($item);
         $commentHandler->moveByTarget($dstInstanceId, $item->id);
     }
 }